【问题标题】:How can I get all the applications that are currently running on android?如何获取当前在 android 上运行的所有应用程序?
【发布时间】:2017-07-25 18:39:02
【问题描述】:

我想在我的 android 设备上获取所有正在运行的应用程序。也许,需要使用PackageManager?我已经尝试习惯PackageManager,但我没有成功,也许,你有更好的决定?

【问题讨论】:

  • 所有正在运行的应用程序或所有已安装的应用程序?

标签: android android-intent


【解决方案1】:

使用下面的代码,您可以获得正在运行的应用程序列表

ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfo = am.getRunningAppProcesses();

【讨论】:

    【解决方案2】:

    您可以使用ActivityManager检测有关正在运行的进程的信息。

    我认为您应该在这里检查这些相同的问题:

    How to get the list of running application

    How to get all the tasks that are running currently

    【讨论】:

      【解决方案3】:

      我建议以下线程。您的问题已经得到解答。

      ActivityManager 有方法 getRunningTasks(int)。 ActivityManager 似乎 成为您正在寻找的解决方案。

       final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
          final List<RunningTaskInfo> recentTasks = activityManager.getRunningTasks(Integer.MAX_VALUE);
      
          for (int i = 0; i < recentTasks.size(); i++) 
          {
              Log.d("Executed app", "Application executed : " +recentTasks.get(i).baseActivity.toShortString()+ "\t\t ID: "+recentTasks.get(i).id+"");         
          }
      

      Read here

      【讨论】:

        猜你喜欢
        • 2016-03-29
        • 1970-01-01
        • 1970-01-01
        • 2018-09-19
        • 1970-01-01
        • 1970-01-01
        • 2015-10-21
        • 1970-01-01
        • 2016-03-28
        相关资源
        最近更新 更多