0

我想在 Android 系统中收集 App 激活序列。

例如

如果用户先打开 Youtube App,然后切换到 Gmail App,再切换回 Youtube App 等等,那么顺序是这样的:

Youtube Gmail Youtube ...

Google Play 或其他地方是否有可用的应用程序来实现这一目标?

实施起来简单吗?纯App解决方案能否实现目标?

是否需要root设备?

4

1 回答 1

0

您需要定期轮询此函数。您可以进一步编写逻辑以删除随后重复的应用程序标签。

private string getActiveApplicationLabel(){
  String appLabel = null;
  ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  List l = am.getRunningAppProcesses();
  Iterator i = l.iterator();
  PackageManager pm = this.getPackageManager();
  while(i.hasNext()) {
  ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(i.next());

  try {
    CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName,  
     PackageManager.GET_META_DATA));
     appLabel = c.toString();
    }catch(Exception e) {
      //Name Not FOund Exception
    }

 }
 return appLabel;
}
于 2013-01-19T19:10:27.667 回答