I want to get all the tasks that are performed in android.I discovered getRunningTasks in the ActivityManager, but from android-5.0 getRunningTasks may not complete all the tasks (in my case it gives the main screen and my application).
Also, is it possible to find the task that the user is currently interacting with?
Any help would be greatly appreciated.
Thank.
Change . I am using the following code snippet. But it gives me only one process (this is my application). Even if I open other applications, it does not show them. I run this One Plus 2.
@Override
protected void onHandleIntent(Intent intent) {
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
getRunningApps();
}
}, 0, 1000);
}
public void getRunningApps() {
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final List<ActivityManager.RunningAppProcessInfo> recentTasks = activityManager.getRunningAppProcesses();
for (int i = 0; i < recentTasks.size(); i++)
{
Log.d("Executed app", "Application executed : " +recentTasks.get(i).pkgList[0]+ "\t\t ID: "+recentTasks.get(i).pid+"");
}
}
source
share