6

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

4 Answers 4

15

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

Sign up to request clarification or add additional context in comments.

6 Comments

I dont know the package name, i will get url from server and download it and save it in sdcard, how do i get package name to check
Thanks, I requesting my server url to get apk, for that scenario, how can i get get package name, if there is any way to get package name from apk file?
you can't get it from the apk file, you will get it from the packageManager after you install it .
No doubt your post is really helpful , but i am getting a exception "java.lang.RuntimeException: Adding window failed" and " E/AndroidRuntime(7554): Caused by: android.os.TransactionTooLargeException 05-14 11:37:25.305: E/AndroidRuntime(7554): at android.os.BinderProxy.transact(Native Method) 05-14 11:37:25.305: E/AndroidRuntime(7554): at android.view.IWindowSession$Stub$Proxy.add(IWindowSession.java:516) 05-14 11:37:25.305: E/AndroidRuntime(7554): at android.view.ViewRootImpl.setView(ViewRootImpl.java:494) "
to solve this issue i got a link stackoverflow.com/questions/11451393/…
|
1
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.

Comments

1

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
                    }

        }

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.