I want to check that whether whatsapp is installed in mobile or not if installed then show toast "installed" and if not installed then show Toast "Not Installed".How can I do that Kindly help.
after getting list of packages search for com. whatsapp(package name of whats app given on official webiste Whatsapp). Thats it..
Open the WhatsApp Messenger app on your Android. You can find it on your home screen or Apps tray.
The date when your WhatsApp account was made is located in the Terms of Service section.
Step 1: Open https://play.google.com/store in your web browser. Step 2: Type the name of the app in the search bar to look for the app.
You can use this code. It will check if package is installed.
public class Example extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Put the package name here...
boolean installed = isAppInstalled("com.whatsapp");
if(installed) {
System.out.println("App is already installed on your phone");
} else {
System.out.println("App is not currently installed on your phone");
}
}
private boolean isAppInstalled(String packageName) {
PackageManager pm = getPackageManager();
boolean app_installed;
try {
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
app_installed = true;
}
catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}
}
based on @eliasz-kubala answer this will work for me on Android 11 after only adding this to Manifest
<manifest
...>
<queries> <package android:name="com.whatsapp" /> </queries>
<application ....>
</application>
</manifest>
and Then use this Kotlin function
private fun isAppInstalled(packageName: String): Boolean {
val pm: PackageManager = getPackageManager()
return try {
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES)
true
} catch (e: PackageManager.NameNotFoundException) {
false
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With