I have a button in a service where the user clicks on it the recent apps dialog will appear, but I don't know a proper way to achieve that, can anyone help?
Asked
Active
Viewed 1,187 times
3 Answers
2
ActivityManager has method getrunningtasks() .
ActivityManager activity_manager = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
then call the getRunningtasks() to get a list of the current Running tasks :
List<RunningTaskInfo> recentTasks = activityManager.getRunningTasks(Integer.MAX_VALUE);
for (int i = 0; i < recentTasks.size(); i++) {
Log.d("Executed app",
"Application executed : "
+ recentTasks.get(i).baseActivity.toShortString()
+ "\t\t ID: " + recentTasks.get(i).id + "");
}
and please add the permission to get the running tasks in your manifest file like the following :
<uses-permission android:name="android.permission.GET_TASKS"/>
Hope that helps .
-
Thanks first, but is there a way to bring up the system recent apps window, like by pressing the recent app button on the nav bar – xXJJJasonMokXx Jan 25 '14 at 16:46
-
But that does not do what I want doed it?? – xXJJJasonMokXx Jan 26 '14 at 16:46
-
Can I access it with accessibility service? – xXJJJasonMokXx Jan 27 '14 at 04:49
2
Recent apps can be opened using the TOGGLE_RECENTS Intent.
Intent intent = new Intent ("com.android.systemui.recent.action.TOGGLE_RECENTS");
intent.setComponent (new ComponentName ("com.android.systemui", "com.android.systemui.recent.RecentsActivity");
startActivity (intent);

Ava
- 2,038
- 3
- 23
- 45
0
You can make your own dialog to show recent apps
ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
then you can get all running apps with
getRunningTasks

Orhan Obut
- 8,756
- 5
- 32
- 42