获取Android的活跃应用程序的名称

编程入门 行业动态 更新时间:2024-10-23 07:28:29
本文介绍了获取Android的活跃应用程序的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图做一个程序,显示所有的活动应用程序。

I am trying to make a program that shows all the active applications.

我到处找,但只能找到code,显示在包的名称只。

I searched everywhere but could only find code that shows the package name only.

这将是很大的帮助,如果你高手能告诉我如何显示所有活动的应用程序名

It would be of great help if you masters can tell me how to display all the active application name

推荐答案

你有没有尝试使用 ActivityManager.getRunningAppProcesses()? 下面是示例code检索名称:

Did you try using ActivityManager.getRunningAppProcesses()? Here is the sample code for retrieving names:

ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE); List l = am.getRunningAppProcesses(); Iterator i = l.iterator(); PackageManager pm = this.getPackageManager(); while(i.hasNext()) { ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(i.next()); try { CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA)); Log.w("LABEL", c.toString()); }catch(Exception e) { //Name Not FOund Exception } }

更多推荐

获取Android的活跃应用程序的名称

本文发布于:2023-11-09 05:44:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571531.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   活跃   名称   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!