【发布时间】:2013-03-14 21:31:30
【问题描述】:
我想分别列出已安装和系统应用程序。下面是我的代码
List<ApplicationInfo> appList = packageManager.getInstalledApplications(0);
if(appList != null && !appList.isEmpty()){
for (ApplicationInfo appInfo : appList) {
Intent intent = packageManager.getLaunchIntentForPackage(appInfo.packageName);
if(intent != null){
ComponentName componentName = intent.getComponent();
if((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
//It is a system app
}else{
//It is an installed app.
}
}
}
}
我想在点击 listview 时启动每个应用程序。但 componentName .getClassName() 对某些人显示为“com.android.internal.app.ResolverActivity”联系人、地图等应用程序...如何获得此类应用程序的确切类名。我无法使用 ResolveInfo,因为很难对应用程序进行分类。
如何使用包名获取应用程序的准确类名?
提前致谢
【问题讨论】:
-
我在运行 4.2.2 的 Galaxy Nexus 上运行了您的示例代码,但没有安装任何显示为 ResolverActivity 的应用程序。你能给我们多介绍一点背景吗?你在做什么?也许这不是您回答的直接途径...但是您让我很好奇为什么您会看到 ResolverActivity 而我没有。
-
我用的是 Galaxy Tab 2.2
标签: android class-names