2013-03-25 59 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