Polarbear0106 Polarbear0106 - 1 year ago 43
Android Question

How can I check if the user has installed an app?

I see apps that offer rewards for downloading an app for an instance, and they know if you have installed the app or not. How do they do that?


define a Method that return true is the PackageManafer can find it:


 private boolean checkThisApp(String uri) {
        PackageManager myPackageManager = getPackageManager();
        boolean app_installed;
        try {
            myPackageManager.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
            app_installed = true;
        catch (PackageManager.NameNotFoundException e) {
            app_installed = false;
        return app_installed;

and use it in the Activity/Fragment like:

boolean isAppInstalled = checkThisApp("com.facebook.katana");