如何在一个列表中获取已安装的应用程序的名称 [英] How to get the installed application name in a list
本文介绍了如何在一个列表中获取已安装的应用程序的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经试过这样:
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
这code给我安装的应用程序的软件包名称等的列表,但我只想要的应用程序名称是作为一个字符串类型列表。我该怎么办?
this code gives me the list of the installed app's package name and etc. But I want only the application name's as a string type list. what should I do?
推荐答案
您可以使用下面的code :::请参阅本的链接
You can use the below code ::: Refer this LINK
public class AppList extends Activity {
....
private ArrayList results = new ArrayList();
@Override
public void onCreate(Bundle savedInstanceState) {
.....
PackageManager pm = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List list = pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
for (ResolveInfo rInfo : list) {
results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
Log.w("Installed Applications", rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
}
}
}
在上面的code结果是安装在数组列表应用
in the above code "results" is the array list apps installed
这篇关于如何在一个列表中获取已安装的应用程序的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文