我需要一点点的帮助获得了最近可以说是开/使用的5应用程序的信息。
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);
然后我用:
String output = "the last application you've executed is '"+task.id+"' and the PID is '"+task.toString()+"'";
但它没有工作搞好。我想我在正确的轨道与ActivityManager跟踪最新的应用程序。
But it didnt work out well. I think im on the right track with ActivityManager to track the latest app.
感谢您!
和你们我只需要获得足够的信息,这样我就可以运行它们。
And ye i only need to get enough information so i can run them.
//西门
RecentTaskInfo
不覆盖的toString()
。尝试使用 task.ComponentName.toString();
或 task.description
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
有关您看到字符串的解释,在这里检查我的答案是:Getting奇怪的文字后面,在Android项目EditText.toString()方法。为什么呢?
For an explanation of the string you see, check my answer here: Getting weird text back with EditText.toString() method in Android project. Why?