[英]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.