2013-03-25 44 views
2

我想要的清单都安装和系统应用separately.Below是我的代码如何从android的包名获取类名?

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.But的组件名.getClassName()显示了作为点击“ com.android.internal.app.ResolverActivity“对于某些应用程序,如联系人,地图等....我怎么能得到这种类型的应用程序的确切类名称。我不能使用ResolveInfo,因为它很难分类应用。

如何获取使用包名的应用程序的确切类名?

由于提前

+0

我跑你的示例代码在Galaxy Nexus的运行4.2.2,我没有得到任何安装的应用程序显示为ResolverActivity。你能给我们多一点背景吗?你在做什么?也许这不是你答案的直接路径......但你让我好奇你为什么看到ResolverActivity,而我不是。 – 2013-03-25 12:11:52

+0

我使用Galaxy Tab 2.2 – 2013-03-25 12:13:56

回答

0

你可以问packageManager:

CharSequence label = ""; 
for (ApplicationInfo appInfo : appList)  
    label = packageManager.getApplicationLabel(appInfo); 
+0

packageManager.getApplicationLabel()返回应用程序的名称。我想获取类名 – 2013-03-25 12:16:46