Reputation: 399
I need a little bit help getting information about the last lets say 5 application that was opened/used.
ActivityManager m = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
RecentTaskInfo task = m.getRecentTasks(5,0).get(0);
Then i used:
String output = "the last application you've executed is '"+task.id+"' and the PID is '"+task.toString()+"'";
But it didnt work out well. I think im on the right track with ActivityManager to track the latest app.
Thank you!
And ye i only need to get enough information so i can run them.
//Simon
Upvotes: 1
Views: 3233
Reputation: 40381
RecentTaskInfo
does not override toString()
. Try using task.ComponentName.toString();
or task.description
http://www.devdiv.com/android/docs/reference/android/app/ActivityManager.RecentTaskInfo.html
http://developer.android.com/reference/android/content/ComponentName.html
For an explanation of the string you see, check my answer here: Getting weird text back with EditText.toString() method in Android project. Why?
Upvotes: 2