1. 程式人生 > >根據包名取得應用全部資訊ResolveInfo

根據包名取得應用全部資訊ResolveInfo

	public static ResolveInfo findAppByPackageName(String mPackageName)
	{
		ResolveInfo newAppInfo = null;
		// 用於存放臨時應用程式
		List<ResolveInfo> mTempAllApps;
		
		PackageManager TempPackageManager = mContext.getPackageManager();
		Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
		mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
		mainIntent.setPackage(mPackageName);
		mTempAllApps = TempPackageManager.queryIntentActivities(mainIntent, 0);
		newAppInfo = mTempAllApps.get(0);
		
		return newAppInfo;
	}