How to:‎ > ‎

Detect if an app is installed

If you ever need to know if a particular app is installed on the user's device, you can use the PackageManager.  From a Context class (e.g. an Activity or a Service) you can call getPackageManager().  This gives you a variety of methods, one of which is getPackageInfo().  Below is a method you might use.  You might call it like this:

isAppInstalled("com.simexusa.campusmaps_full");

private boolean isAppInstalled(String uri) {
PackageManager pm = getPackageManager();
boolean installed = false;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
installed = true;
} catch (PackageManager.NameNotFoundException e) {
installed = false;
}
return installed;
}
Comments