2013-12-23 144 views

回答

5

以顯示已安裝的應用程序的列表,你可以試試這個

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); 
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); 
final List pkgAppsList = context.getPackageManager().queryIntentActivities(mainIntent, 0); 

您將獲得在ResolveInfo所有必要的數據,以啓動一個應用程序。您可以檢查ResolveInfo

或試試這個代碼

PackageManager pm = this.getPackageManager(); 

    Intent intent = new Intent(Intent.ACTION_MAIN, null); 
    intent.addCategory(Intent.CATEGORY_LAUNCHER); 

    ArrayList<ResolveInfo> list = (ArrayList<ResolveInfo>) 
     pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED); 
     for (ResolveInfo rInfo : list) { 
     System.out.println("Installed Applications " + rInfo.activityInfo.applicationInfo.loadLabel(pm).toString()); 
     }