Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 618
caw Avatar asked Nov 06 '11 23:11

caw


People also ask

Can my app Ask the user to rate their app?

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:

Is it possible to rate an app on Google Play Store?

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.

Should you add a rate me feature 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. So, it is better to add a rate me feature in your app which helps you to get the feedback.

How to add Android-rate in Android app development?

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.


1 Answers

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 */ } 
like image 142
xbakesx Avatar answered Oct 12 '22 22:10

xbakesx