StackTips

How to Add Rate On Google Play Button in Android

Use the following code snippet to, add an option in the app that allows the user to rate and review your app on Google Play or Amazon store. You can call getPackageName() and construct the Intent to open the on Google play app using Intent.ACTION_VIEW.

public static void reviewOnGooglePlay(Activity activity) {
        final String appPackageName = activity.getPackageName();
        try {
            activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException e) {
        }
        activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
}

If you have published your application on Amazon play store. You can use the following code snippet.

public static void reviewOnAmazon(Activity activity) {
        final String appPackageName = activity.getPackageName();
        try {
            activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("amzn://apps/android?p=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException anfe) {
        }
        activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.amazon.com/gp/mas/dl/android?p=\"" + appPackageName)));

    }