The Google Play In-App Review API lets you prompt users to submit Play Store ratings and reviews without the inconvenience of leaving your app or game.Example is as shown below:
In this tutorial I will show you how to add it in your application.
1.Add the required dependancy in your build.gradle
implementation 'com.google.android.play:core:1.8.2'
2.Create an instance of ReviewManager which will help in starting the flow.
ReviewManager manager = ReviewManagerFactory.create(this);
3.Request a reviewInfo object
ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
// We can get the ReviewInfo object
ReviewInfo reviewInfo = task.getResult();
} else {
// There was some problem, continue regardless of the result.
}
});
4.Launch the in app review dialog
Task<Void> flow = manager.launchReviewFlow(activity, 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.
});
Your whole code should appear like below:
ReviewManager manager;
private ReviewInfo reviewInfo;
manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
reviewInfo = task.getResult();
Task<Void> flow = manager.launchReviewFlow(YOURACTIVITY.this, reviewInfo);
flow.addOnCompleteListener(taskdone -> {
// This is the next follow of your app
});
}
});
// other action, please DO NOT add any flow after Task because i will run parawell, you must to add in addOnCompleteListener
Follow this link to test your app
https://developer.android.com/guide/playcore/in-app-review/test