private boolean isAppInstalled(String packageName) {
PackageManager pm = getPackageManager();
boolean installed = false;
try {
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
installed = true;
} catch (PackageManager.NameNotFoundException e) {
installed = false;
}
return installed;
}
Detect an app installed [duplicate]
Question
Could I know If there is a specific app installed in the phone programmatically? My app would make a process in one way or in other depending on that. How could I get this information?
Thanks!!
Solution
OTHER TIPS
You must know the package name to check weather the application is installed or not
say if package name is like com.myapp.name
use the following to existence
boolean isExists;
try
{
getPackageManager().getPackageInfo("com.myapp.name", PackageManager.GET_ACTIVITIES);
isExists = true;
}
catch(NameNotFoundException e)
{
isExists = false;
// Sep 11, 2013 8:39:47 PM
Log.e("Exception", "NameNotFoundException" + String.valueOf(e.getMessage()));
e.printStackTrace();
}
Must use try catch around to handling expected error when NameNotFoundException is thrown
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow