我目前正在开发一个Android应用程序..我必须记录加速度计传感器事件坐标与事件时间.我得到了传感器事件时间戳,如"3497855005850",但我无法将事件时间戳转换为用户可读的日期时间格式.提前谢谢
如何将SensorEvent时间戳转换为unix时间戳?
我目前正在开发一个Android应用程序.每当用户安装/下载新的第三方应用程序时,我都必须记录任何新安装的应用程序名称.如果用户正在安装新应用,我该如何收到通知.提前致谢.
public class ApplicationBroadcastService extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
System.out.print("-------");
}
}
Run Code Online (Sandbox Code Playgroud)
<receiver android:name=".applicationlog.ApplicationBroadcastService">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
但是当我安装/卸载任何应用程序时,我仍然没有输入onReceive方法.
这是解决方案:
我在Manifest文件中做了一些小改动.
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
现在它工作正常.. :)再次感谢@willytate
如何在Android手机上获取已安装的第三方应用程序列表.
我可以使用下面的代码获取应用程序列表,但我只想要第三方应用程序.
PackageManager pm = context.getPackageManager();
appInstalModel.setAppName(p.applicationInfo.loadLabel(context.getPackageManager()).toString());
appInstalModel.setAppPkg(p.packageName);
appInstalModel.setAppVersionName(p.versionName);
Run Code Online (Sandbox Code Playgroud) 在Android中,我如何获得应用程序安装日期以及如何安装应用程序大小.
我使用下面的代码来获取应用程序大小,但它不正确
List packs = getPackageManager().getInstalledPackages(0);
for(i=0;i<packs.size();i++) {
PackageInfo p = packs.get(i);
ApplicationInfo appInfo =p.applicationInfo;
long fileSize = new FileInputStream(appInfo.sourceDir).getChannel().size();
}
Run Code Online (Sandbox Code Playgroud)
请帮帮我..谢谢,
我正在使用下面的代码来获取设备上所有当前正在运行的进程。如何获得正在运行的进程开始时间?
activityMan = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
process = activityMan.getRunningAppProcesses();
for (Iterator iterator = process.iterator(); iterator.hasNext();) {
RunningAppProcessInfo runningAppProcessInfo = (RunningAppProcessInfo) iterator
.next();
pSname= runningAppProcessInfo.processName;
System.out.println(pSname);
}
Run Code Online (Sandbox Code Playgroud)