Skip to content

Instantly share code, notes, and snippets.

@wutianlong
Created March 27, 2017 07:05
Show Gist options
  • Save wutianlong/5d573ee179b51a6ca409850c431c5587 to your computer and use it in GitHub Desktop.
Save wutianlong/5d573ee179b51a6ca409850c431c5587 to your computer and use it in GitHub Desktop.
judge app is installed
public class IsInstalled {
public static boolean isIntalled(Context context, String packageName) {
boolean exist = false;
PackageManager pm = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(intent, 0);
for (ResolveInfo resolveInfo : resolveInfoList) {
if (resolveInfo.activityInfo.packageName.equals(packageName)) {
exist = true;
}
}
return exist;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment