Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 way for this?

like image 523
Cilenco Avatar asked Jun 28 '13 20:06

Cilenco


People also ask

How do you know if an app has been installed?

On your Android phone, open the Google Play store app and tap the menu button (three lines). In the menu, tap My apps & games to see a list of apps currently installed on your device.

How can I check if an app is installed from a Web page on an Iphone?

Show activity on this post. iOS Safari has a feature that allows you to add a "smart" banner to your webpage that will link either to your app, if it is installed, or to the App Store. You do this by adding a meta tag to the page.


1 Answers

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:

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  =   appInstalledOrNot("com.facebook.android");  
            if(installed)
            {
            //This intent will help you to launch if the package is already installed
            Intent LaunchIntent = 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");
            }
        }
        private boolean appInstalledOrNot(String uri)
        {
            PackageManager pm = getPackageManager();
            boolean app_installed = false;
            try
            {
                   pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
                   app_installed = true;
            }
            catch (PackageManager.NameNotFoundException e)
            {
                   app_installed = false;
            }
            return app_installed ;
    }
    }
like image 182
Nick Avatar answered Sep 19 '22 19:09

Nick