Identify app is installed in the device

If you want to know the other app is installed or not, just using PackageManager.


public boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
boolean app_installed = false;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
} catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}

String uri means package name like com.example.app. 

if(appInstalledOrNot(com.example.app)==false){
<-- app is not installed-->
}
else{
<-- app is installed-->
}


Comments

Popular posts from this blog

Clear the app data programmatically in android

convert an integer to a string in java

Print the large string values in android log cat.