kumar_android
kumar_android

Reputation: 2263

Check App is installed on device android code

I downloaded apk file from url(my server) and save it in sdcard. If user install it from sdcard, I want to know, whether is any notification that app is installed successfully or is app istalled in device. Is there any callback on installed app

Upvotes: 6

Views: 8615

Answers (4)

Wahib Ul Haq
Wahib Ul Haq

Reputation: 4415

In Youtube Player API, you can access YoutubeIntents class and use isYoutubeInstalled to verify if device has the Android app or not.

Upvotes: 1

Houcine
Houcine

Reputation: 24181

try this code :

protected boolean isAppInstalled(String packageName) {
        Intent mIntent = getPackageManager().getLaunchIntentForPackage(packageName);
        if (mIntent != null) {
            return true;
        }
        else {
            return false;
        }
    }

to get the package name of the app easily : just search your app in the google play website , and then you will take the id parameter ( it is the package name of the app) . Example : you will search on Youtube app on google play , and you will find it in this url :

https://play.google.com/store/apps/details?id=com.google.android.youtube&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5nb29nbGUuYW5kcm9pZC55b3V0dWJlIl0.

the package name is the id param, so it is : com.google.android.youtube

And then when you want to test , you will just have :

String packageName = "com.google.android.youtube";
boolean isYoutubeInstalled = isAppInstalled(packageName);

PLUS : if you want to get the list of all installed apps in you device , you can find your answer in this tutorial

Upvotes: 15

jaumard
jaumard

Reputation: 8292

Use this to check if an application is installed

PackageManager pm = context.getPackageManager();

        List<ApplicationInfo> list = pm.getInstalledApplications(0);

        for (int i = 0; i < list.size(); i++) {         
            if(list.get(i).packageName.equals("com.my package")){
                    //do what you want
                    }

        }

Upvotes: 1

SVS
SVS

Reputation: 200

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);

You'll get the list of all installed applications on Android.

Upvotes: 1

Related Questions