所有正在该设备上运行的活动中的应用的列表 [英] List of all of the activities in our application that are running on the device
问题描述
如何获得在我们的应用程序在设备上运行的所有活动的列表。
How to get the list of all activities in our application that are running on the device.
例如:PDF生成和电子邮件活动包括:
For example: pdf generation and email activities included.
我可以检查与code的活动,如:
I can check for activities with the code like:
ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
// get the info from the currently running task
List< ActivityManager.RunningTaskInfo > taskInfo = am.getRunningTasks(1);
Log.d("topActivity", "CURRENT Activity ::"
+ taskInfo.get(0).topActivity.getClassName());
ComponentName componentInfo = taskInfo.get(0).topActivity;
componentInfo.getPackageName();
然而,这将提供有关正在运行的活动是顶级活动的信息。
This will however give information about the running activity which is the top activity.
我的想法是白名单运行,使我的第三方应用程序可以运行它,而在设备上的活动。所以基本上,我需要在应用程序中所有正在运行的活动。
My idea is to whitelist the activities running so that my third party application can run it while on the device. So I basically need all of the running activities in the application.
推荐答案
这是方式来获得应用程序中所有正在运行的活动 -
This is the way to get all the running activities in the application -
try {
ActivityInfo[] list = getPackageManager().getPackageInfo(getPackageName(),PackageManager.GET_ACTIVITIES).activities;
for(int i = 0;i< list.length;i++)
{
System.out.println("List of running activities"+list[i].name);
}
}
catch (NameNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
这篇关于所有正在该设备上运行的活动中的应用的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!