Created
March 27, 2017 07:05
-
-
Save wutianlong/5d573ee179b51a6ca409850c431c5587 to your computer and use it in GitHub Desktop.
judge app is installed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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