how to check whether user has whatsapp installed or not??? I want app like whenever I click on users number it should display message whether that user has whatsapp or not... please help me.I have listview of contacts info means name and number..I want to check whether that particular number has whatsapp installed or not on click of listview item????
Asked
Active
Viewed 1,934 times
-2
-
5Possible duplicate of [Check if application is installed - Android](http://stackoverflow.com/questions/18752202/check-if-application-is-installed-android) – Ed Holloway-George Jun 27 '16 at 10:38
-
I have listview of contacts info means name and number..I want to check whether that particular number has whatsapp installed or not on click of listview item???? – user6076314 Jun 27 '16 at 10:51
2 Answers
1
Use packagemanager to get the installed app info: for whatsapp package name is com.whatsapp
boolean installed = appInstalledOrNot("com.whatsapp"); //the method returns boolean value here
private boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
boolean app_installed;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
}
catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}

SaravInfern
- 3,338
- 1
- 20
- 44
-
boolean installed = appInstalledOrNot("com.whatsapp"); just call the method wherever needed – SaravInfern Jun 27 '16 at 10:48
-
1I want to check whether whatsapp installed for that particular number or not???Will this method remain same in this condition also?? – user6076314 Jun 27 '16 at 11:00
1
public static boolean isInstalled(String packageName) {
if (StringUtils.equalsNull(packageName)) {
return false;
}
PackageManager pm = ContextProvider.getApplicationContext()
.getPackageManager();
List<PackageInfo> list = pm
.getInstalledPackages(PackageManager.PERMISSION_GRANTED);
for (PackageInfo p : list) {
if (packageName.equals(p.packageName)) {
return true;
}
}
return false;
}

bernard_yang
- 21
- 3