-2

Adding Rating feature an android app, As i have published one of my app on Playstore now i want to add rate this app feature to that app but i don't know how to do that. Please let me know if anyone have any idea. Thankyou

Ankita Sethi
  • 43
  • 2
  • 11
  • 1
    Hi Ankita, Google does not provide any direct API to rate application on Play Store however it can be achieved simply by navigating user on Play Store with your application and ask them to rate over there. I have added an answer for your reference. You simply need to put that in anywhere in your application and call that. thank – Geek Mar 20 '17 at 08:41
  • 1
    Does this answer your question? ["Rate This App"-link in Google Play store app on the phone](https://stackoverflow.com/questions/10816757/rate-this-app-link-in-google-play-store-app-on-the-phone) – Yoav Feuerstein May 25 '20 at 14:16

2 Answers2

0

You can not rate your app directly. You need to redirect the user to the playstore and ask them to rate 5 star.

//To check if the playsytore app is installed or not
private boolean MyStartActivity(Intent aIntent) {
    try
    {
        startActivity(aIntent);
        return true;
        }
    catch (ActivityNotFoundException e)
    {
        return false;
        }
}

//On click event for rate this app button
public void btnRateAppOnClick(View v) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    //Try Google play
    intent.setData(Uri.parse("market://details?id=cs.nizam.funeralrites"));
    if (!MyStartActivity(intent)) {
        //Market (Google play) app seems not installed, let's try to open a webbrowser
        intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=cs.nizam.funeralrites"));
        if (!MyStartActivity(intent)) {
            //Well if this also fails, we have run out of options, inform the user.
            Snackbar.make(v, "Could not open Android market, please install the market app.", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
            }
        }
}
Nizam
  • 5,698
  • 9
  • 45
  • 57
0

There is no API provided by Google to rate application on Play Store. However it can be achieved this by navigating user to your app on Play Store and ask user to rate over there. This can be achieved by calling below simple method. You just need to call this function and rest it will do itself.

public static void rateThisApplication(Context context)
{

    Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    // To count with Play market backstack, After pressing back button,
    // to taken back to our application, we need to add following flags to intent.
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET |
            Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    try
    {
        context.startActivity(goToMarket);
    }
    catch (ActivityNotFoundException e)
    {
        context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())));
    }
    finally
    {
        uri = null;
        goToMarket = null;
    }
}
Geek
  • 1,510
  • 14
  • 17
  • Ok you mean i can add this code anywhere in my app and rating feature will added automatically. But you also ask to call it but where to call this method in app ? – Ankita Sethi Mar 20 '17 at 09:19
  • @AnkitaSethi, Rate App UI you have to create. For example you may have seen rate us button on any other applications. Like wise you have create UI, that could consist of stars or a simple button, text view saying Rate Us and onclick of that you have to call above function. – Geek Mar 20 '17 at 09:48
  • @AnkitaSethi, Hi Ankita, if this answer helped you please mark it as answer :) – Geek Mar 20 '17 at 10:40