September 30, 2020

Integrate In-App Review API in Android

By Mohit Agrawal

Let’s explore Google’s In-App Review API for app rating

in app review android 1

As an android developer, we always want good ratings from the users. It is because Google play store rating plays a crucial role in the app’s popularity. The question is how do you ask your user to rate the app 🙁?

The most used approach is by showing a pop-up and redirect the user to the play store. It makes a negative impact because the user has to leave the app and what is a possible chance that he will come back ?. It makes a bad user experience.

Fortunately, Google has recently announced the In-App Review API. Using this you can show the rating widget in the app itself without leaving the app.

Isn’t it awesome 😃?

Let’s learn everything about In-App review API in detail.


Requirements and Guidelines

Before starting the actual coding part, there are some points or requirements in order to use In-App review API.

These are the requirements:

  • Android devices (phones and tablets) running Android 5.0 (API level 21) or higher that have the Google Play Store installed.
  • Chrome OS devices that have the Google Play Store installed.
  • To integrate in-app reviews in your app, your app must use version 1.8.0 or higher of the Play Core library.

You need to take care of following points:

  • Display the review card as-is, without tampering or modifying the existing design in any way, including size, opacity, shape, or other properties.
  • Do not add any overlay on top of the card or around the card.
  • Review dialog should not be programmatically removed (It will automatically be removed based on user actions).
  • To protect user privacy and avoid API misuse, this API has a limited quota per user. Hence this functionality should not be triggered on a button click.
  • Before presenting the Review card, the app should not ask user opinions like “Do you like the app?” or “Give this app 5 stars”, etc.

Let’s implement In-App review API

1 STEP: In-App review comes with the Play Core Library. Open your app level gradle file and implement the library like this.

// Play core library
implementation ""
// This is to show fallback dialog alert.
implementation ""

2 STEP: We need to create an instance of the ReviewManager class. Because it provides all the required methods to start the In-App review flow.

Open your MainActivity.kt and paste the below code.

import android.content.DialogInterface
import android.os.Bundle

class MainActivity : AppCompatActivity() {

    private var reviewManager: ReviewManager? = null

    override fun onCreate(savedInstanceState: Bundle?) {

    private fun init() {
        reviewManager = ReviewManagerFactory.create(this)
        button.setOnClickListener {

    fun showRateApp() {
        val request = reviewManager!!.requestReviewFlow()
        request.addOnCompleteListener { task: Task<ReviewInfo?> ->
            if (task.isSuccessful) {
                // We can get the ReviewInfo object
                val reviewInfo = task.result
                val flow =
                    reviewManager!!.launchReviewFlow(this, reviewInfo)
                flow.addOnCompleteListener { task1: Task<Void?>? -> }
            } else {
                // There was some problem, continue regardless of the result.
                // show native rate app dialog on error

    private fun showRateAppFallbackDialog() {
            .setTitle("Rate us")
            .setMessage("Liked us? Please rate us on play store")
            .setPositiveButton("Okay") { dialog, which -> }
                "Not now"
            ) { dialog, which -> }
            ) { dialog, which -> }
            .setOnDismissListener(DialogInterface.OnDismissListener { dialog: DialogInterface? -> })

Let me explain the above code.

  • After creating the instance of Review Manager class, we need to call requestReviewFlow(). This will return the ReviewInfo object.
  • Now call the method launchReviewFlow() using the object of ReviewInfo.
  • We are also setting up the usual rate app dialog if the review request fails.

How to test In-App Review API

Here the implementation is easy but it becomes a little tricky when it comes to the testing.

In-app reviews require your app to be published in Play Store. However, you can test your integration without publishing your app to production using either internal test tracks or internal app sharing.

You can find more info on the testing part on the android developer page. If you have any queries, please let me know in the comments section below.

android-in-app-review-app-example 2


Help me to grow our YouTube Channel: More tutorials like this

I hope this blog post is useful for you, do let me know your opinion in the comment section below.
I will be happy to see your comments down below 👏.
Thanks for reading!!!