由网友(三岁奶猫)分享简介:如何获得在我们的应用程序在设备上运行的所有活动的列表。How to get the list of all activities in our application that are running on the device.例如:PDF生成和电子邮件活动包括:For example: pdf generat...
如何获得在我们的应用程序在设备上运行的所有活动的列表。
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();
}
相关推荐
最新文章