当我用谷歌搜索时,我遇到了这段代码。
ActivityManager m = (ActivityManager) ctx.getSystemService( ctx.ACTIVITY_SERVICE );
List<RunningTaskInfo> runningTaskInfoList = m.getRunningTasks(10);
Iterator<RunningTaskInfo> itr = runningTaskInfoList.iterator();
while(itr.hasNext()){
RunningTaskInfo runningTaskInfo = (RunningTaskInfo)itr.next();
int id = runningTaskInfo.id;
CharSequence desc= runningTaskInfo.description;
int numOfActivities = runningTaskInfo.numActivities;
String topActivity = runningTaskInfo.topActivity.getShortClassName();
}
这告诉我有多少任务正在运行以及任务中的活动数量。
我目前正在开发一个应用程序,并希望跟踪我自己的应用程序中哪些活动仍然处于活动状态。基本上我想获取 int numOfActivities = runningTaskInfo.numActivities; 的内容
我怎样才能做到这一点?