2

When I tried to open play store listing of my app via intent, it is opening playstore app and shows this message, "to view this content, install and setup a web browsing app". Please see the screenshot.

Screenshot

I have set chrome as default browsing app. this is the code

private void launchRateUS() {
        try {
            Intent rateIntent = rate("market://details?id=" + getPackageName());
            startActivity(rateIntent);
        } catch (ActivityNotFoundException e) {
            Intent rateIntent = rate("https://play.google.com/store/apps/details?id=" + getPackageName());
            startActivity(rateIntent);
        }
    }


private Intent rate(String url) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("%s?id=%s", url, getPackageName())));
        int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
        if (Build.VERSION.SDK_INT >= 21) {
            flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        } else {
            flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
        }
        intent.addFlags(flags);
        return intent;
    }

What is wrong with the code? How to show playstore listing instead of this message?

1
  • My bad, I simply copy-pasted from another class and was adding package details twice.
    – Sony
    Commented May 23, 2018 at 10:35

2 Answers 2

6

You are doubling up your ?id=packagename in your rate function. Just use the url you pass in.

private Intent rate(String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
...
1
  • my bad, I copy pasted from another class and didn't notice that.
    – Sony
    Commented May 23, 2018 at 10:38
0

Try it

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));

startActivity(browserIntent);

Not the answer you're looking for? Browse other questions tagged or ask your own question.