how to implement Rate Us in android

I am always using below code which is useful for us:

Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())); 
startActivity(rateIntent);

In think it will help full for you.


This error occurs when running on a device without the Google PlayStore. I guess you might be running this on a emulator device which doesn't have Playstore and hence the error.

Implement using try catch as follows:

try{
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+getPackageName())));
    }
    catch (ActivityNotFoundException e){
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+getPackageName())));
    }

Idk why you get the Error, but this should actually work. I also do it like this:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));

But keep in mind that this would crash, if you are testing it on an Emulator/ a device without a play store. So I would suggest you to wrap it in a try and catch

Tags:

Android