【问题标题】:List out installed/running applications in android programmatically [duplicate]以编程方式列出android中已安装/正在运行的应用程序[重复]
【发布时间】:2012-07-09 08:28:14
【问题描述】:

可能重复:
How to get a list of installed android applications and pick one to run

我们使用的是安卓手机。

  1. 如何列出All Installed Applications。
  2. 如何列出All Running Applications。

帮助我。谢谢。

【问题讨论】:

  • 如何通过程序列出所有应用程序?

标签: android


【解决方案1】:

要获取 Android 上安装的活动/应用程序列表:

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);

引用自:How to get a list of installed android applications and pick one to run

检查所有正在运行的应用程序

ActivityManager actvityManager = (ActivityManager)
this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();

推荐人:http://www.dreamincode.net/forums/topic/138412-android-20-list-of-running-applications/

注意:上述函数将返回 API 21 以下的正确结果,不推荐使用 21 及以上的函数。

【讨论】:

  • 谢谢。它列出了所有的应用程序。如何识别以编程方式列出当前正在运行的应用程序?
  • 谢谢波马拉。它对我和其他人都很有用。
  • 使用上面的代码我得到了所有最近的应用程序,有没有办法过滤系统应用程序并只列出最近安装的应用程序
  • @Ponmalar 我在 ActivityManager activityManager = (ActivityManager); 中获得“ActivityManager 无法解析为变量”;知道为什么吗?
  • 以这种方式列出正在运行的应用程序不适用于 API 版本 >=21,这将只返回您的应用程序
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-06-04
  • 2012-06-23
  • 2012-10-06
  • 2011-06-25
  • 1970-01-01
相关资源
最近更新 更多