有没有办法获取有关设备中安装的应用程序的详细信息?我想实现一个至少可以包含已安装应用程序名称的应用程序。提前致谢。
问问题
105 次
2 回答
2
您可以使用 PackageManager:
final PackageManager pm = getPackageManager();
//get a list of installed apps.
List<ApplicationInfo> packages = pm
.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
Log.d(TAG, "Installed package :" + packageInfo.packageName);
Log.d(TAG, "Launch Activity :"
+ pm.getLaunchIntentForPackage(packageInfo.packageName));
Log.d(TAG, "Application name :" + pm.getApplicationLabel(packageInfo));
}// the getLaunchIntentForPackage returns an intent that you can use with startActivity()
编辑:您可以使用getApplicationLabel()来获取名称,如上所示。
http://qtcstation.com/2011/02/how-to-launch-another-app-from-your-app/
于 2012-07-11T15:50:40.557 回答
0
干得好:
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final List appsList = context.getPackageManager().queryIntentActivities(intent, 0);
于 2012-07-11T15:50:12.237 回答