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 ?
2 Answers
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!!
-
-
-
can i just use this ? `` Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "play.google.com/store/apps/…)); startActivity(intent); `` Commented Jan 23, 2020 at 13:26
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
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" +getPackageName())));