How to get information about all running actions in android programmatically?

In android, you get information about starting actions by watching Logcat.

For example, if you open the camera, it logs into Logcat.

Is there any way to get this information programmatically?

+4
source share
1 answer
ActivityManager m = (ActivityManager) getSystemService(Context.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; String topActivity = runningTaskInfo.topActivity.getShortClassName(); int numOfActivities = runningTaskInfo.numActivities; } 

Note. . You must specify the android.permission.GET_TASKS permission in the manifest file.

+10
source

Source: https://habr.com/ru/post/1401796/


All Articles