Android Rate App feature implementation, in this blog you’ll learn how using few lines of code you can create an in app Alert Dialog Box that’ll prompt user to Rate and review your app in the Google Play Store.

Need some career advice or prepping for an Android developer interview? Hit me up on, and let's chat!

Android Rate App
Android Rate App for Google Play Store

Android Rate App Importance

Having a Rate my App feature in your app is important because:

  1. It improves your Android app App store optimisation in Google Play Store. (If user gives your app a good rating!)
  2. Improves your App Play store and Google Search Ranking.
  3. Helps you to improve your app and release a better version because now you actually understand your user needs better.
  4. Helps you to acquire more User, and get more downloads.
  5. Improves your app revenue from in App ads and in app purchases
Android Rate App
Android Rate App for Google Play Store

To start with creating such a method, first create a Java class named In this Java file code the following:

package com.myapp.packagename
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;


public class AppRater {

    private final static String APP_TITLE = "MY_APP";// App Name
    private final static String APP_PNAME = "com.myapp.packagename";// Package Name

    private final static int DAYS_UNTIL_PROMPT = 3;//Min number of days
    private final static int LAUNCHES_UNTIL_PROMPT = 3;//Min number of launches

    public static void app_launched(Context mContext) {
        SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);
        if (prefs.getBoolean("dontshowagain", false)) { return ; }

        SharedPreferences.Editor editor = prefs.edit();

        // Increment launch counter
        long launch_count = prefs.getLong("launch_count", 0) + 1;
        editor.putLong("launch_count", launch_count);

        // Get date of first launch
        Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
        if (date_firstLaunch == 0) {
            date_firstLaunch = System.currentTimeMillis();
            editor.putLong("date_firstlaunch", date_firstLaunch);

        // Wait at least n days before opening
        if (launch_count >= LAUNCHES_UNTIL_PROMPT) {
            if (System.currentTimeMillis() >= date_firstLaunch +
                    (DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) {
                showRateDialog(mContext, editor);


    public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor) {

        String t1 = mContext.getString(R.string.enjoy) + " " + APP_TITLE + mContext.getString(R.string.enjoy_using);
        AlertDialog materialAlertDialogBuilder = new AlertDialog.Builder(mContext)
                .setTitle("Rate our App")
                .setPositiveButton("Yes, Sure", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
                .setNeutralButton("Remind me Later", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                .setNegativeButton("Don't Ask Again", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (editor != null) {
                            editor.putBoolean("dontshowagain", true);


As seen in the above code, we will prompt the user after an interval of minimum 3 days and after 3 minimum opens, to rate our app in the Google play store.

We’ve kept User experience in mind and kept interval as low as possible to not irritate our app user.

We’re using AndroidX in this project therefore, using Android Material AlertDialog, the prompt to rate the app will be created.

Now where ever you wish to create the prompt (Recommended to create Alert on Home Screen!) for user, by simple importing this ‘RateMyApp.class’ and calling following method in onCreate();


To create a custom Dialog box, learn how to create custom styles in android, link here.

Therefore if your android app really has a great experience to offer to the Google play store market users, then you must implement this ‘Android Rate App’ feature and give your app a BOOST! All the best! 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

You May Also Like