How to add Rate the App feature in Android Studio

This code is work after publish your app on google play console and on amazon app store. This code is also work on emulator. In emulator google play store is not installed so app is show on browser.

Important Note !!

Your apk name must be your app package name otherwise code not work.

Example com.companyname.appname.apk

Uri uri = Uri.parse("market://details?id=" + getPackageName());
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
}
try {
    startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
    startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
}

Leave a Reply

Your email address will not be published. Required fields are marked *