Android Rate My App Dialog
Before I show you the code I used to create this good looking “rate my app” dialog boxes I want you to know that these can be annoying and don’t recommend them in all situations.
Guide lines I use:
- Don’t prompt until 5 days after the user has installed it.
- Don’t prompt until the app has been launched 7 times.
- Only include it if the app is free.
So for the code.
First create a new class and call it AppRater and set up some constants.
So far we created a new class and added some constants that you can change as needed. To make it more plug and play you could create the Strings APP_NAME and APP_PACKAGE_NAME and assign their values in the app_launch section by using something like below.
So let’s look at the code in the app_launched section.
That section should be pretty straight forward. Create shared preferences, launch counter and date first launched. If the launch counter is greater or equal to the value set earlier, and it has been at least 5 days defined by DAYS_UNTIL_PROMPT, show the rate dialog.
Next we will work on creating the dialog box and the event handler for the dialog. Dialog will basically have 3 buttons and each one needs to have an on click event handler. So let’s look at the code.
So we create a dialog with a title, icon and a message and make it so the user can not cancel the dialog without selecting one of the 3 buttons.
- Rate Now – sets preferences so it will not show the dialog again and opens the Google Play Store to your app so the user can rate it.
- Later – just dismisses the dialog. Here you can add code to not show it again for x amount of times. If you leave it like this the user will be prompted each time the application is opened until they select “Rate Now” or “No, Thanks”
- No, Thanks – sets preferences to not show the dialog again.
Now all you have to do is include it in your activity’s onCreate method like so.
That’s it. If you would like to see a how to create a more customizable “rate my app” dialog check out the following snippet on AndroidSnippets. As you will see, that article gave me the idea for my article. If you want a more customizable view it is a good place to start but for my needs an AlertDialog did the trick.
Since these dialog boxes can be annoying and as much as we want public praise for an app it may have a negative impact. So what I recommend is if your app already has analytics built in use it to measure the impact the dialog has. Add event tracking code to measure how the dialog is used. You could set a value of 1 for each time a user clicks on “Rate Now” and 0 for the two other buttons this way when you average the values of the event you would see the impact. After adding the dialog you would also want to keep an eye on how it is impacting your ratings. If it is impacting it negatively you should consider improving the app as first priority and if you have no idea where the improvement is needed you maybe better of removing the dialog.