Android的发展:查找/获得最近使用过的应用程序 [英] Android Development: Find/get recently used Apps

查看:199
本文介绍了Android的发展:查找/获得最近使用过的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一点点的帮助获得了最近可以说是开/使用的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

有关您看到字符串的解释,在这里检查我的答案是:<一href="http://stackoverflow.com/questions/5750007/getting-weird-text-back-with-edittext-tostring-method-in-android-project-why/5750073#5750073">Getting奇怪的文字后面,在Android项目Edit​​Text.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?

这篇关于Android的发展:查找/获得最近使用过的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆