Skip to content Skip to sidebar Skip to footer

Find Out If App Is Installed

I think the question says it all: What is the best way to find out if the user has installed Facebook or Whatsapp on his phone? Do I have to go over the package or what is the best

Solution 1:

This was question was answered here. You can using the following piece of code to check for the package name

com.facebook.android OR com.facebook.katana

Code:

publicclassExampleextendsActivity
    {
        @OverrideprotectedvoidonCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            //Put the package name here...booleaninstalled=   appInstalledOrNot("com.facebook.android");  
            if(installed)
            {
            //This intent will help you to launch if the package is already installedIntentLaunchIntent= getPackageManager()
                .getLaunchIntentForPackage("com.facebook.android");
        startActivity(LaunchIntent);


                      System.out.println("App already installed om your phone");


            }
            else
            {
                System.out.println("App is not installed om your phone");
            }
        }
        privatebooleanappInstalledOrNot(String uri)
        {
            PackageManagerpm= getPackageManager();
            booleanapp_installed=false;
            try
            {
                   pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
                   app_installed = true;
            }
            catch (PackageManager.NameNotFoundException e)
            {
                   app_installed = false;
            }
            return app_installed ;
    }
    }

Post a Comment for "Find Out If App Is Installed"