获取正在运行的任务的Android类别信息
在Android中,我可以使用如下代码获取正在运行的任务和活动:
(ActivityManager.RunningTaskInfo) this.mActivityManager.getRunningTasks()
然后我可以获取包名称,类名称等。
我的问题是是否有办法从中获取“类别”信息?或者任何人都可以提出替代解决方案?例如,当我启动一个应用程序时,类别是
cat=[android.intent.category.LAUNCHER]
In Android, I can get the running tasks and activities using code like tis:
(ActivityManager.RunningTaskInfo) this.mActivityManager.getRunningTasks()
Then I can get the package name, class name etc.
My question is that whether there is a way to get the "category" information from it? Or anyone can suggest an alternative solution? for example, when I launch an app, the category is
cat=[android.intent.category.LAUNCHER]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不太确定你的意思,但也许以下就是你想要的:通过调用 getIntent() 检索活动中的意图,并在 Intent 对象上调用方法 getCategories( )。此方法将返回一个包含类别字符串的集合。
I am not really sure what you mean, but maybe the following is what you want: retrieve the intent in your activity by calling
getIntent()
, and on the Intent object call the methodgetCategories()
. This method will return a set with category strings.我不太确定这是否能解决您的问题,但您可以使用 ActivityManager 的 getRecentTasks(int, int) API 用于获取有关最近任务的信息。它返回 ActivityManager.RecentTaskInfo 对象的列表,其中包含信息关于用于启动任务的意图。您还可以使用
RecentTaskInfo.id
字段将任务与正在运行的任务进行映射。I am not really sure, whether this would solve your problem, but you may use ActivityManager's getRecentTasks(int, int) API to get information about the recent tasks. It returns a list of ActivityManager.RecentTaskInfo objects, which have information about the intent used to launch the task. You can also use
RecentTaskInfo.id
field to map the task with the running tasks.我没有找到直接的方法,但这可能会有所帮助:
I found no direct way of doing it, but this may help: