【问题标题】:How to profile the App uses in Android?如何分析应用在 Android 中的使用情况?
【发布时间】:2013-01-19 18:29:21
【问题描述】:

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

例如

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

Youtube Gmail Youtube ...

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

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

是否需要root设备?

【问题讨论】:

    标签: android profiling root


    【解决方案1】:

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

    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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-07
      • 1970-01-01
      • 1970-01-01
      • 2011-06-09
      相关资源
      最近更新 更多