以编程方式列出 android 中已安装/正在运行的应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11391451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
List out installed/running applications in android programmatically
提问by Sathish Sathish
Possible Duplicate:
How to get a list of installed android applications and pick one to run
We have using a android mobile.
我们使用的是安卓手机。
- How to list out
All Installed Applications
. - How to list out
All Running Applications
.
- 如何列出
All Installed Applications
。 - 如何列出
All Running Applications
。
Help Me. Thanks.
帮我。谢谢。
回答by Ponmalar
To get the list of activities/applications installed on Android:
要获取 Android 上安装的活动/应用程序列表:
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
Referred from: How to get a list of installed android applications and pick one to run
引用自:如何获取已安装的 android 应用程序列表并选择一个运行
To check all running applications
检查所有正在运行的应用程序
ActivityManager actvityManager = (ActivityManager)
this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();
Referred From: http://www.dreamincode.net/forums/topic/138412-android-20-list-of-running-applications/
引用自:http: //www.dreamincode.net/forums/topic/138412-android-20-list-of-running-applications/
Note: Above described function will return correct result for below API 21, for 21 and above it's deprecated.
注意:对于低于 API 21 的上述函数将返回正确的结果,对于 21 及以上版本已弃用。