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
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”). Follow these guidelines as you determine how to integrate in-app reviews in your app:
Unless the user does not love or hate your app, they are not likely to go out of their way to rate your app. Since high rating indicates the success of your app, and even criticism is required to make the application better.
Unless the user does not love or hate your app, they are not likely to go out of their way to rate your app. Since high rating indicates the success of your app, and even criticism is required to make the application better. So, it is better to add a rate me feature in your app which helps you to get the feedback.
Add the support Library in build.gradle file and add Android-Rate dependency in the dependencies section. This library have a function which redirects the user to google play store and allows them to rate the application. It helps in getting the feedback.
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 */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With