As you see from the other post you have linked, there isn't a way for the app to know if the user has left a review or not. And for good reason.
Think about it, if an app could tell if the user has left a review or not, the developer could restrict certain features that would only be unlocked if the user leaves a 5/5 rating. This would lead the other users of Google Play to not trust the reviews and would undermine the rating system.
The alternative solutions I have seen is that the app reminds the user to submit a rating whenever the app is opened a specific number of times, or a set interval. For example, on every 10th time the app is opened, ask the user to leave a rating and provide a "already done" and "remind me later" button. Keep showing this message if the user has chosen to remind him/her later. Some other apps developers show this message with an increasing interval (like, 5, 10, 15nth time the app is opened), because if a user hasn't left a review on the, for example, 100th time the app was opened, it's probably likely s/he won't be leaving one.
This solution isn't perfect, but I think it's the best you have for now. It does lead you to trust the user, but realize that the alternative would mean a potentially worse experience for everyone in the app market.
I implemented this a while back, to some extent. It is impossible to know whether or not a user has rated an app, to prevent ratings from becoming a currency (some developers might add an option like "Rate this app and get so and so in the app for free").
The class I wrote provides three buttons, and configures the dialog so that it is only shown after the app has been launched n times (users have a higher chance of rating the app if they've used it a bit before. Most of them are unlikely to even know what it does on the first run):
public class AppRater {
private final static String APP_TITLE = "App Name";// App Name
private final static String APP_PNAME = "com.example.name";// 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);
}
}
editor.commit();
}
public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor) {
final Dialog dialog = new Dialog(mContext);
dialog.setTitle("Rate " + APP_TITLE);
LinearLayout ll = new LinearLayout(mContext);
ll.setOrientation(LinearLayout.VERTICAL);
TextView tv = new TextView(mContext);
tv.setText("If you enjoy using " + APP_TITLE + ", please take a moment to rate it. Thanks for your support!");
tv.setWidth(240);
tv.setPadding(4, 0, 4, 10);
ll.addView(tv);
Button b1 = new Button(mContext);
b1.setText("Rate " + APP_TITLE);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
dialog.dismiss();
}
});
ll.addView(b1);
Button b2 = new Button(mContext);
b2.setText("Remind me later");
b2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
ll.addView(b2);
Button b3 = new Button(mContext);
b3.setText("No, thanks");
b3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (editor != null) {
editor.putBoolean("dontshowagain", true);
editor.commit();
}
dialog.dismiss();
}
});
ll.addView(b3);
dialog.setContentView(ll);
dialog.show();
}
}
Integrating the class is as simple as adding:
AppRater.app_launched(this);
To your Activity. It only needs to be added to one Activity in the entire app.
I think what you are trying to do is probably counter-productive.
Making it easy for people to rate apps is generally a good idea, as most people who bother do so because they like the app. It is rumoured that the number of ratings affects your market rating (although I see little evidence of this). Hassling users into rating - through nag screens - is likely to cause people to clear the nag through leaving a bad rating.
Adding the capability to directly rate an app has caused a slight decrease in the numerical ratings for my free version, and a slight increase in my paid app. For the free app, my 4 star ratings increased more than my 5 star ratings, as people who thought my app was good but not great started to rate it as well. Change was about -0.2. For the paid, change was about +0.1. I should remove it from the free version, except I like getting lots of comments.
I put my rating button into a settings (preference) screen, where it does not affect normal operation. It still increased my rating rate by a factor of 4 or 5. I have no doubt that if I tried nagging my users into making a rating, I would get lots of users giving me bad ratings as a protest.
This solution is very similar to those presented above. The only difference is that you are going to be able to delay the prompt of the rating dialog per launches and days. If the remind me later button is pressed, then I will delay the pop up for 3 days and 10 launches. The same is done for those that selected to rate it, however the delays is longer (not to bother the user so soon in case that he has actually rated the app. This can be changed to not be shown again, then you will have to alter the code to your like). Hope it helps somebody!
public class AppRater {
private final static String APP_TITLE = "your_app_name";
private static String PACKAGE_NAME = "your_package_name";
private static int DAYS_UNTIL_PROMPT = 5;
private static int LAUNCHES_UNTIL_PROMPT = 10;
private static long EXTRA_DAYS;
private static long EXTRA_LAUCHES;
private static SharedPreferences prefs;
private static SharedPreferences.Editor editor;
private static Activity activity;
public static void app_launched(Activity activity1) {
activity = activity1;
Configs.sendScreenView("Avaliando App", activity);
PACKAGE_NAME = activity.getPackageName();
prefs = activity.getSharedPreferences("apprater", Context.MODE_PRIVATE);
if (prefs.getBoolean("dontshowagain", false))
return;
editor = prefs.edit();
EXTRA_DAYS = prefs.getLong("extra_days", 0);
EXTRA_LAUCHES = prefs.getLong("extra_launches", 0);
// 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 + EXTRA_LAUCHES))
if (System.currentTimeMillis() >= date_firstLaunch + (DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000) + EXTRA_DAYS)
showRateDialog();
editor.commit();
}
public static void showRateDialog() {
final Dialog dialog = new Dialog(activity);
dialog.setTitle("Deseja avaliar o aplicativo " + APP_TITLE + "?");
LinearLayout ll = new LinearLayout(activity);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setPadding(5, 5, 5, 5);
TextView tv = new TextView(activity);
tv.setTextColor(activity.getResources().getColor(R.color.default_text));
tv.setText("Ajude-nos a melhorar o aplicativo com sua avaliação no Google Play!");
tv.setWidth(240);
tv.setGravity(Gravity.CENTER);
tv.setPadding(5, 5, 5, 5);
ll.addView(tv);
Button b1 = new Button(activity);
b1.setTextColor(activity.getResources().getColor(R.color.default_text));
b1.setBackground(activity.getResources().getDrawable(R.drawable.rounded_blue_box));
b1.setTextColor(Color.WHITE);
b1.setText("Avaliar aplicativo " + APP_TITLE + "!");
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Configs.sendHitEvents(Configs.APP_RATER, Configs.CATEGORIA_ANALYTICS, "Clique", "Avaliar", activity);
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + PACKAGE_NAME)));
delayDays(60);
delayLaunches(30);
dialog.dismiss();
}
});
ll.addView(b1);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) b1.getLayoutParams();
params.setMargins(5, 3, 5, 3);
b1.setLayoutParams(params);
Button b2 = new Button(activity);
b2.setTextColor(activity.getResources().getColor(R.color.default_text));
b2.setBackground(activity.getResources().getDrawable(R.drawable.rounded_blue_box));
b2.setTextColor(Color.WHITE);
b2.setText("Lembre-me mais tarde!");
b2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Configs.sendHitEvents(Configs.APP_RATER, Configs.CATEGORIA_ANALYTICS, "Clique", "Avaliar Mais Tarde", activity);
delayDays(3);
delayLaunches(10);
dialog.dismiss();
}
});
ll.addView(b2);
params = (LinearLayout.LayoutParams) b2.getLayoutParams();
params.setMargins(5, 3, 5, 3);
b2.setLayoutParams(params);
Button b3 = new Button(activity);
b3.setTextColor(activity.getResources().getColor(R.color.default_text));
b3.setBackground(activity.getResources().getDrawable(R.drawable.rounded_blue_box));
b3.setTextColor(Color.WHITE);
b3.setText("Não, obrigado!");
b3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Configs.sendHitEvents(Configs.APP_RATER, Configs.CATEGORIA_ANALYTICS, "Clique", "Não Avaliar", activity);
if (editor != null) {
editor.putBoolean("dontshowagain", true);
editor.commit();
}
dialog.dismiss();
}
});
ll.addView(b3);
params = (LinearLayout.LayoutParams) b3.getLayoutParams();
params.setMargins(5, 3, 5, 0);
b3.setLayoutParams(params);
dialog.setContentView(ll);
dialog.show();
}
private static void delayLaunches(int numberOfLaunches) {
long extra_launches = prefs.getLong("extra_launches", 0) + numberOfLaunches;
editor.putLong("extra_launches", extra_launches);
editor.commit();
}
private static void delayDays(int numberOfDays) {
Long extra_days = prefs.getLong("extra_days", 0) + (numberOfDays * 1000 * 60 * 60 * 24);
editor.putLong("extra_days", extra_days);
editor.commit();
}
}
The Buttons have a specific color and background. The background is as shown in this xml file:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppRate.with(this)
.setStoreType(StoreType.GOOGLEPLAY) //default is GOOGLEPLAY (Google Play), other options are
// AMAZON (Amazon Appstore) and
// SAMSUNG (Samsung Galaxy Apps)
.setInstallDays((byte) 0) // default 10, 0 means install day
.setLaunchTimes((byte) 3) // default 10
.setRemindInterval((byte) 2) // default 1
.setRemindLaunchTimes((byte) 2) // default 1 (each launch)
.setShowLaterButton(true) // default true
.setDebug(false) // default false
//Java 8+: .setOnClickButtonListener(which -> Log.d(MainActivity.class.getName(), Byte.toString(which)))
.setOnClickButtonListener(new OnClickButtonListener() { // callback listener.
@Override
public void onClickButton(byte which) {
Log.d(MainActivity.class.getName(), Byte.toString(which));
}
})
.monitor();
if (AppRate.with(this).getStoreType() == StoreType.GOOGLEPLAY) {
//Check that Google Play is available
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) != ConnectionResult.SERVICE_MISSING) {
// Show a dialog if meets conditions
AppRate.showRateDialogIfMeetsConditions(this);
}
} else {
// Show a dialog if meets conditions
AppRate.showRateDialogIfMeetsConditions(this);
}
}
The default conditions to show rate dialog is as below:
App is launched more than 10 days later than installation. Change via AppRate#setInstallDays(byte).
App is launched more than 10 times. Change via AppRate#setLaunchTimes(byte).
App is launched more than 1 days after neutral button clicked. Change via AppRate#setRemindInterval(byte).
App is launched X times and X % 1 = 0. Change via AppRate#setRemindLaunchTimes(byte).
App shows neutral dialog (Remind me later) by default. Change via setShowLaterButton(boolean).
To specify the callback when the button is pressed. The same value as the second argument of DialogInterface.OnClickListener#onClick will be passed in the argument of onClickButton.
Setting AppRate#setDebug(boolean) will ensure that the rating request is shown each time the app is launched. This feature is only for development!.
Optional custom event requirements for showing dialog
You can add additional optional requirements for showing dialog. Each requirement can be added/referenced as a unique string. You can set a minimum count for each such event (for e.g. "action_performed" 3 times, "button_clicked" 5 times, etc.)
You can use a specific theme to inflate the dialog.
AppRate.with(this).setThemeResId(int);
Custom dialog
If you want to use your own dialog labels, override string xml resources on your application.
<resources>
<string name="rate_dialog_title">Rate this app</string>
<string name="rate_dialog_message">If you enjoy playing this app, would you mind taking a moment to rate it? It won\'t take more than a minute. Thanks for your support!</string>
<string name="rate_dialog_ok">Rate It Now</string>
<string name="rate_dialog_cancel">Remind Me Later</string>
<string name="rate_dialog_no">No, Thanks</string>
</resources>
Check that Google Play is available
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) != ConnectionResult.SERVICE_MISSING) {
}
object Constants {
const val APP_TITLE = "App Name"
const val APP_NAME = "com.example.name"
const val RATER_KEY = "rater_key"
const val LAUNCH_COUNTER_KEY = "launch_counter_key"
const val DO_NOT_SHOW_AGAIN_KEY = "do_not_show_again_key"
const val FIRST_LAUNCH_KEY = "first_launch_key"
const val DAYS_UNTIL_PROMPT: Int = 3
const val LAUNCHES_UNTIL_PROMPT: Int = 3
}
strings.xml
<resources>
<string name="rate_description">If you enjoy using %1$s, please take a moment to rate it. Thanks for your support!</string>
<string name="rate_now">Rate now</string>
<string name="no_thanks">No, thanks</string>
<string name="remind_later">Remind me later</string>
<string name="market_uri">market://details?id=%1$s</string>
</resources>
Java & Kotlin solution (In-app review API by Google in 2020):
First, in your build.gradle(app) file, add following dependencies (full setup here)
dependencies {
// This dependency is downloaded from the Google’s Maven repository.
// So, make sure you also include that repository in your project's build.gradle file.
implementation 'com.google.android.play:core:1.8.0'
}
Add this method to your Activity:
void askRatings() {
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();
Task<Void> flow = manager.launchReviewFlow(this, reviewInfo);
flow.addOnCompleteListener(task2 -> {
// 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.
});
} else {
// There was some problem, continue regardless of the result.
}
});
}
Create a ReviewManager instance and request ReviewInfo object. The ReviewInfo object to be pre-cached and then can trigger "launchReviewFlow" to present the Review card to the user.
private var reviewInfo: ReviewInfo? = null
val manager = ReviewManagerFactory.create(context)
val request = manager.requestReviewFlow()
requestFlow.addOnCompleteListener { request ->
if (request.isSuccessful) {
//Received ReviewInfo object
reviewInfo = request.result
} else {
//Problem in receiving object
reviewInfo = null
}
reviewInfo?.let {
val flow = reviewManager.launchReviewFlow(this@MainActivity, it)
flow.addOnCompleteListener {
//Irrespective of the result, the app flow should continue
}
}
Note : It is suggested to show the review flow after the user has experienced enough of your app or game.
When to request an in-app review:
Trigger the in-app review flow after a user has experienced enough of your app or game to provide useful feedback.
Do not prompt the user excessively for a review. This approach helps minimize user frustration and limit API usage (see the section on quotas).
Your app should not ask the user any questions before or while presenting the rating button or card, including questions about their opinion (such as “Do you like the app?”) or predictive questions (such as “Would you rate this app 5 stars”).
Few points before testing this:
While testing new functionalities, mostly we create a new project that would have new ApplicationId, make sure you give an ApplicationId that is already released and available in the play store.
If you have given feedback in the past for your app, in-app review API’s launchReviewFlow will not present any Review card. It simply triggers a success event.
Due to quota limitations, calling a launchReviewFlow method might not always display a dialog. It should not be linked with any click event.
All those libraries are not the solution for the problem in this post.
This libraries just open a webpage to the app on google play.
Instead this Play core library has more consistent interface.
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.
Generally, the in-app review flow (see figure 1) can be triggered at
any time throughout the user journey of your app. During the flow, the
user has the ability to rate your app using the 1 to 5 star system and
to add an optional comment. Once submitted, the review is sent to the
Play Store and eventually displayed.
You can call Google In-App Review API. You do not need to count, because of Google handle this issue for you. If someone gave stars or comment previously, Google will not show again this prompt.
2-) added below code snippet where appropriate place and time.
Use the ReviewInfo instance to launch the in-app review flow. Wait until the user has completed the in-app review flow before your app continues its normal user flow
fun inAppReview() {
val reviewManager = ReviewManagerFactory.create(this)
val requestReviewFlow = reviewManager.requestReviewFlow()
requestReviewFlow.addOnCompleteListener { request ->
if (request.isSuccessful) {
// We got the ReviewInfo object
val reviewInfo = request.result
val flow = reviewManager.launchReviewFlow(this, reviewInfo)
flow.addOnCompleteListener {
// Call back
}
} else {
Log.d("Error: ", request.exception.toString())
// There was some problem, continue regardless of the result.
}
}
}