本文介绍了获取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的活跃应用程序的名称
发布评论