Define a method that returns true if the PackageManager can find it:
Example:
private boolean checkThisApp(String uri) {
PackageManager myPackageManager = getPackageManager();
boolean app_installed;
try {
myPackageManager.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
}
catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}
and use it in the Activity/Fragment like:
boolean isAppInstalled = checkThisApp("com.facebook.katana");
1
solved How can I check if the user has installed an app?