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; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter