-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Implementing a Rate Me Feature
When you have a published app on the Google Play Store, it is important that you get feedback from your users. Unless your users absolutely love or absolutely hate your app, they're not likely to go out of their way to rate your app on the Play Store. Since high ratings are indicative and predictive of the success of your app, it is critical that you nudge users into rating your app. This guide covers two complementary approaches:
- Attaching a
market://Rate Me intent to an explicitButton(sends the user out to the Play Store listing) - Showing the Play Store's built-in rating card inside your app via the Play In-App Review API
This method is simpler to implement and is less annoying to users because it requires them to first, find your Rate Me Button, and second, actually click it and follow through. That said, it is also less likely to get users to actually rate your app. As with any feature that does not directly add to the user experience, you must weigh the negative impact of bugging the user to rate your app with the benefit that ratings have on your app's success.
To implement this method, you just need a Button or View with an onClick handler. For instance, let's say you have the xml-defined Button:
<Button
android:id="@+id/btnRate"
android:text="Rate Me!"
android:onClick="rateMe" >
</Button>The onClick handler points to a method called rateMe, so in the Activity file where this Button lives, you must define:
public void rateMe(View view) {
try {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + this.getPackageName())));
} catch (android.content.ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=" + this.getPackageName())));
}
}The try/catch block is necessary because the user may not have the Play Store installed, in which case we direct the user to a browser version of the Play Store. In either case, notice that this code block can actually be placed anywhere in your app. It's wisest, however, to play nice with the user and only launch this intent when they most expect it (like when they click on a Rate Me Button).
For prompting users to rate the app without leaving it, the canonical Google-supported approach is the Play In-App Review API, which presents the Play Store rating card inside your app and submits the review without an Activity transition. This replaces older third-party "AppRate" libraries — the previously recommended MSF-Jarvis/AppRate and the original TimotheeJeannin/AppRate have both been unmaintained for years (the MSF-Jarvis fork no longer exists, and the original has had no commits since 2015).
Add the dependency in your app-level build.gradle:
dependencies {
implementation 'com.google.android.play:review:2.0.2'
// For Kotlin coroutines extensions:
// implementation 'com.google.android.play:review-ktx:2.0.2'
}Then request a ReviewInfo (this happens off the UI thread) and launch the flow when you reach a natural break point in your app:
import com.google.android.play.core.review.ReviewException;
import com.google.android.play.core.review.ReviewInfo;
import com.google.android.play.core.review.ReviewManager;
import com.google.android.play.core.review.ReviewManagerFactory;
import com.google.android.play.core.review.model.ReviewErrorCode;
import com.google.android.gms.tasks.Task;
ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
ReviewInfo reviewInfo = task.getResult();
Task<Void> flow = manager.launchReviewFlow(this, reviewInfo);
flow.addOnCompleteListener(flowTask -> {
// The flow has finished. The API does not indicate whether
// the user reviewed or not, or even whether the review
// dialog was shown, so continue your app flow either way.
});
} else {
@ReviewErrorCode int reviewErrorCode =
((ReviewException) task.getException()).getErrorCode();
// Log or handle the error code.
}
});Important constraints from the Play In-App Review docs:
- Google Play enforces a time-bound quota —
launchReviewFlow()may complete without showing any dialog at all if the user has already been prompted recently. Your code must continue normally either way; you cannot detect whether the dialog appeared or what the user rated. - Do not wire the API up to an always-visible "Rate this app" button — because of the quota, that path produces a broken UX when the dialog is suppressed. The manual
market://intent above is still the right choice for an explicit button. - Do not ask users opinion-survey questions before invoking the API (e.g. "Did you enjoy the app?") — Play Store policy prohibits gating the review card on a separate sentiment prompt.
- Trigger from a natural break (e.g. after completing a level, finishing a flow), and only after the user has spent enough time in the app to give meaningful feedback.
Created by CodePath with much help from the community. Contributed content licensed under cc-wiki with attribution required. You are free to remix and reuse, as long as you attribute and use a similar license.
Finding these guides helpful?
We need help from the broader community to improve these guides, add new topics and keep the topics up-to-date. See our contribution guidelines here and our topic issues list for great ways to help out.
Check these same guides through our standalone viewer for a better browsing experience and an improved search. Follow us on twitter @codepath for access to more useful Android development resources.