Polarbear0106 Polarbear0106 - 1 year ago 75
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?

Answer Source

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"); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download