如何以编程方式获取Android中其他应用程序的启动时间?

时间:2013-01-24 13:36:44

标签: android time launch

我希望获得Android中所有应用的启动时间。请建议我实现这一目标的任何解决方案。我正在使用此代码。它是杀死非系统应用程序。但它也没有用。任何人都可以建议任何解决方案。感谢

timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {   
           List<RunningAppProcessInfo> appProcesses= activityManager.getRunningAppProcesses();
        for (RunningAppProcessInfo appProcess : appProcesses) {
            try {
            if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
            if (!lastFrontAppPkg.equals((String) appProcess.pkgList[0])) {
            apkInfo = ApkInfo.getInfoFromPackageName(appProcess.pkgList[0], mContext);
                if (apkInfo == null || (apkInfo.getP().applicationInfo.flags && ApplicationInfo.FLAG_SYSTEM) == 1) {
                  // System app                                             continue;
                        } else if (((apkInfo.getP().versionName == null)) || (apkInfo.getP().requestedPermissions == null)) {
                    //Application that comes preloaded with the device
                        continue;
                     } else {
                     lastFrontAppPkg = (String) appProcess.pkgList[0];
                     }
    //kill the app
    //Here do the pupop with password to launch the lastFrontAppPkg if the pass is correct
                         }
                      }
                   }
                 } catch (Exception e) {
                  //e.printStackTrace();
                }
               }                        
             }
           }, 0, 1000);

0 个答案:

没有答案