如何获取当前在Android上运行的所有应用程序?

时间:2017-07-25 10:31:29

标签: android android-intent

我想在我的Android设备上运行所有正在运行的应用程序。也许,需要使用PackageManager?我曾经尝试过TYPE- POST URI - /openmrs-standalone/ws/rest/v1/obs BODY- { "concept" : "5086AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "person" : "610b0696-7529-4b4a-b65b-37336a75962a", "obsDatetime": "2017-07-24T15:33:49+05:30", "encounter": "3bc0672d-ebc6-4e65-aae1-8a1d4de759bf", "value" : "90" } For multiple I am sending TYPE- POST URI - /openmrs-standalone/ws/rest/v1/obs BODY- [{"concept" : "5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ", "person" : "610b0696-7529-4b4a-b65b-37336a75962a", "obsDatetime": "2017-07-24T15:33:49+05:30", "encounter": "3bc0672d-ebc6-4e65-aae1-8a1d4de759bf", "value" : "99" }, { "concept" : "5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "person" : "610b0696-7529-4b4a-b65b-37336a75962a", "obsDatetime": "2017-07-24T15:33:49+05:30", "encounter": "3bc0672d-ebc6-4e65-aae1-8a1d4de759bf", "value" : "185" }] ,但我没有成功,也许,你有更好的决定?

3 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

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

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

How to get the list of running application

How to get all the tasks that are running currently

答案 2 :(得分:0)

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

  

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