简体   繁体   English

对于 API 26 +,如何获取当前在我的设备中运行的所有 android 应用程序?

[英]How can I fetch all the android applications that are presently running in my device for API 26 +?

I've tried using this code to fetch the apps that are running in my device:我尝试使用此代码来获取设备中运行的应用程序:

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

Log.d("apps", String.valueOf(runningAppProcessInfo));

I thought I would get the names of all the apps that are running in the device.我想我会得到设备中运行的所有应用程序的名称。 Instead I get this when I debug:相反,我在调试时得到了这个:

[android.app.ActivityManager$RunningAppProcessInfo@ad46c50] [android.app.ActivityManager$RunningAppProcessInfo@ad46c50]

How do I get the list of all the apps that are presently running?如何获取当前正在运行的所有应用程序的列表?

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+"");         
    }

For more information check this link provided.有关更多信息,请查看提供的此链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查服务是否在Android 8(API 26)上运行? - How to check if a service is running on Android 8 (API 26)? 如何从我的 android 设备中获取所有照片 - How can I get all photos from my android device 如何从我的Android设备访问我的本地REST API? - How can I access my local REST api from my android device? 如何在Android应用程序中获取所有具有互联网许可的应用程序? - How can I get all applications that have the internet permission in Android Applications? 在eclipse android real设备上运行我的程序时,我在LogCat中遇到许多错误,这些错误以及如何解决? - When running my program on eclipse android real device i'm getting many errors in the LogCat what all this errors and how to fix them? 如何修复我的Android Studio IDE? (错误23,24;错误26,13,缺少类和渲染问题) - How can I repair my Android Studio IDE? (Error 23,24 ; Error 26,13 , missing classes and render problems) 如何在android studio java中通过api 26杀死应用程序后创建始终运行的服务检测调用 - How to create service Detaction call always running after killed app over api 26 in android studio java 如果调用取消或停止相同的功能,则重新启动(如果当前在Android中运行) - if called Cancel or stop same function then start fresh if presently running in Android 在其他应用程序运行时,如何防止Java程序滞后? - How can I prevent my Java program from lagging while other applications are running? 如何从我的Android设备中发现UUID? - How can I discover the UUID from my android device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM