androiduser-inputratingvoting

Prompt user to rate an Android app inside the App


In my Android app, I want to prompt the user at some point of time to rate the app in Android market.

Having searched for an approach, I've found some code on this website. This code seems to work very well.

But unfortunately, this code seems to raise a "Forced Close" error message when Android market is not installed on the user's phone. Is there any way to check if Android market is installed and, if not, don't try to execute the code?

The line which raises the error is probably this one as it cannot parse the URI:

mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));

And, by the way, are there any other things which could be improved in that code?

Edit:

A few years later, I've put all the code into a small library project: AppRater on GitHub


Solution

  • 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.