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

Flutter Bloc - Clean Architecture

What's new in android 14?

Dependencies vs Dev Dependencies in Flutter