Prompt user to rate an Android app inside the App
Here's all the code you need, (a conglomeration of Kurt's answer and inferred information, plus the link and the question):
/* This code assumes you are inside an activity */
final Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName());
final Intent rateAppIntent = new Intent(Intent.ACTION_VIEW, uri);
if (getPackageManager().queryIntentActivities(rateAppIntent, 0).size() > 0)
{
startActivity(rateAppIntent);
}
else
{
/* handle your error case: the device has no way to handle market urls */
}
You could also use RateMeMaybe: https://github.com/Kopfgeldjaeger/RateMeMaybe
It gives you quite some options to configure (minimum of days/launches until first prompt, minimum of days/launches until each next prompt if user chooses "not now", dialog title, message etc.). It is also easy to use.
Example usage from README:
RateMeMaybe rmm = new RateMeMaybe(this);
rmm.setPromptMinimums(10, 14, 10, 30);
rmm.setDialogMessage("You really seem to like this app, "
+"since you have already used it %totalLaunchCount% times! "
+"It would be great if you took a moment to rate it.");
rmm.setDialogTitle("Rate this app");
rmm.setPositiveBtn("Yeeha!");
rmm.run();
You can always call getInstalledPackages() from the PackageManager class and check to make sure the market class is installed. You could also use queryIntentActivities() to make sure that the Intent you construct will be able to be handled by something, even if it's not the market application. This is probably the best thing to do actually because its the most flexible and robust.