In-App Review Android Implementation

Shubham Agrawal
4 min readSep 27, 2020

--

Google Play In-App Review

As soon as the review for the app comes into mind, you worry about going to the Playstore, correct?
A review is an integral part that lets the developer know how much the users are enjoying their application. But users generally don’t review much of the apps because they don’t want to go to the play store every time just for the review.

But you, as a developer want users to give ratings and feedback for your application.
So in order to solve this pain of users giving feedback from Playstore, Google developed an In-App Review API for letting users give their feedback directly within the app. Cool, isn’t it?

So lets quickly jump into the coding of this. It’s very easy to implement but the testing is quite a pain if you are a new developer.

Step 1: Add the Play core dependency in your build.gradle file.

implementation 'com.google.android.play:core:1.8.0'

Step 2: Now in your Activity

public class MainActivity extends AppCompatActivity {

private ReviewManager reviewManager;
private ReviewInfo reviewInfo;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

reviewManager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = reviewManager.requestReviewFlow();
request.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
// We can get the ReviewInfo object
reviewInfo = task.getResult();
} else {
// There was some problem, continue regardless of the result.
}
});

// Just to test on some button click show the app review dialog.
btnClick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Task<Void> flow = reviewManager.launchReviewFlow(MainActivity.this, reviewInfo);
flow.addOnCompleteListener(task -> {
// The flow has finished. The API does not indicate whether the user
// reviewed or not, or even whether the review dialog was shown. Thus, no
// matter the result, we continue our app flow.
});
}
});
}
}

Note: The ReviewInfo object is only valid for a limited amount of time. Your app should request a ReviewInfo object ahead of time (pre-cache) but only once you are certain that your app will launch the in-app review flow.

Note: It is not suggested to show the app review dialog on a button click. Please read the guidelines here.

That’s it. The coding part is completed.

Now, the testing part of it.

a) Test using an internal test track

Upload your app to the internal test track and install it on a device with a user account that has access to the internal test track. When using an internal test track, the following conditions must be met:

  1. The user account is part of the Internal Test Track.
  2. The user account is the primary account and it’s selected in the Play Store.
  3. The user account has downloaded the app from the Play Store (the app is listed in the user’s Google Play library).
  4. The user account does not currently have a review for the app.

After the account on the device has downloaded the app at least once from the internal test track and is part of the testers list, you can deploy new versions of the app locally to that device (for example, using Android Studio).

b) Test using an internal sharing app

Alternatively, for rapid iteration, you can use internal app sharing to test your integration. This method lets you quickly test changes by skipping some of the verification that happens with other test tracks.

If you have successfully implemented and uploaded your app to the internal test track, then this is how it would like in real-time.

Screenshots of the Google Play In-App review
Google Play In-App Review

KEY POINTS TO REMEMBER:

  1. If you are using the Internal Sharing app to test this, you won’t be able to submit the review. The submit button is disabled in this case.
  2. After you have successfully tested it, remove your email from the Internal App Testers list to get the actual Public Review Dialog. Otherwise, you would always get a Private Review.
  3. The app review dialog won’t show to users who have already given the ratings on the play store. To test at your end, delete the review from the play store and it will show up.
  4. Sometimes, dialog won’t even show up, because of the quota limit of launchReviewFlow. See here for more info.
  5. You should not depend on the dialog to show up and then you do your remaining work because you don't get any callback whether the user has given the feedback or not.

Done! Happy Coding 😁

Reference:

REACH OUT TO ME:

--

--