1

I've recently started creating an app for Android. I want to add "Rate us" button that sends to the app in Google play store. How to get the URL, and what is the code to do that ?

Mohamed Hassan
  • 191
  • 2
  • 12
  • Welcome to the community. The Package name of your App will append in your Google Play URL. So you can achieve it like this. ```startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" +getPackageName())));``` – Muhammad Farhan Jan 23 '20 at 12:21
  • 1
    Does this answer your question? [How to open the Google Play Store directly from my Android application?](https://stackoverflow.com/questions/11753000/how-to-open-the-google-play-store-directly-from-my-android-application) – Style-7 Jan 24 '20 at 20:13

2 Answers2

3

You can get playstore URL using package name of APP,

Uri uri = Uri.parse("market://details?id=" + context.getPackageName());

or

 Uri uri = Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())

you can use this way:

    Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
                    Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
                    Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())));
    }

Hope it will help!!

Nehal Godhasara
  • 787
  • 3
  • 7
1

First of all, you should upload your App to the Google Play Store. Then, you should go to the profile of your app in store and choose "Copy URL", your url-adress may looks like:

https://play.google.com/store/apps/details?id=<app_name>

To get the URL in App and use it, you should create method with next code-line:

Uri appUrl = Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName() + "")

Final result of code to do that here:

startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=" +getPackageName())));

Main topic: https://developer.android.com/distribute/marketing-tools/linking-to-google-play

Mykola
  • 118
  • 1
  • 14