17

I am using the URI format http://play.google.com/store/apps/details?id=<package_name> described in Linking to Your Apps on Google Play in order to open the app in Android Market or Google Play to install it. But it only opens it in the browser as it would do it on the desktop. And when Install is clicked it asks the user to sign-in to install.

How can I link the app in Google Play so the user can install it?

6
  • This is weird, since on my device the browser straight up refuses to open Market links and opens the Market app. I would go to Settings -> Applications -> Manage applications and clear the defaults for the browser to ensure that isn't causing the problem. If that doesn't work: What device do you have? Have you tried typing the URL directly into the browser and seeing what happens? Where is this link appearing, exactly? (On a web page or in another app?) Apr 23, 2012 at 22:46
  • @MatthewRead I've tried to used the link from a message, QR code, email,... And same thing. Also, I've tried on different android devices, not just one, and same issue.
    – slybloty
    Apr 23, 2012 at 23:26
  • Try replacing http with https. It may look dumb, but try it.
    – iOS
    Apr 24, 2012 at 13:25
  • @SachinShekhar I used both http and https. Even market. And the same result.
    – slybloty
    Apr 24, 2012 at 13:37
  • What's your web browser? Default Android browser and Dolphin HD automatically redirect to Play Store app (or, atleast ask)...
    – iOS
    Apr 24, 2012 at 13:43

7 Answers 7

13

Try directly this if link is originated from an app for Android to handle:

market://details?id=<package_name>

Note: There's no domain and host.

12
  • Interesting that this way works. It directs to the market place properly. Thanks.
    – slybloty
    Apr 24, 2012 at 14:36
  • 3
    This'll only work on the Android device. Trying this in a desktop browser won't work.
    – ale
    Apr 24, 2012 at 15:20
  • @AlEverett Unless there's a market protocol handler in desktop browser to insert domain and host. :)
    – iOS
    Apr 24, 2012 at 15:24
  • In fact, it doesn't work even in Android web browsers. Its intended to use in app development.
    – iOS
    Apr 24, 2012 at 15:26
  • Then if this is an app development question it's in the wrong place.
    – ale
    Apr 24, 2012 at 15:30
7

I'm using the code below and it is working fine with my phone and emulator.

For the phone with Google Play app, it will automatically open the app. For the emulator (without Google Play app), it will automatically open the browser.

try { 
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setData(Uri.parse("market://details?id=com.example"));
  startActivity(intent);
} catch (Exception e) { //google play app is not installed
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.example"));
  startActivity(intent);
}
1
  • 1
    +1 for try/catch. In fact sometimes if there is no Google Play app installed on device, we'll get crash when try to open an app with URL starts with "market://details?id="
    – anticafe
    Jan 4, 2013 at 8:24
1

First off, the user can actually install the app from the market. He just can't do it directly but only make Google remote-install the app via the website, as he would do if he browsed the market on his PC.

Second, what browser are you testing this with? Opera isn't well integrated into Android and won't open Play URLs in the app. In fact I'm not sure even the native browser will.

Maybe you should just use market:// links instead of http://links.

1
  • It's the android browser it opens with instead of the app. The link is accessed from the device. I want the user to be able to install the app by clicking the link and be directed to Market or Google Play.
    – slybloty
    Apr 23, 2012 at 22:37
1

Settings > Applications > All (top tab)
Click Menu button > Reset app preferences

Source: http://www.youtube.com/watch?v=zt_alKha_-s

1
  • It's not working
    – VVB
    Aug 3, 2017 at 9:39
0

I found simple and easy solution.

  1. make a html page any where. <meta http-equiv="REFRESH" content="0; URL=market://details?id=package_name" />
  2. Open browser and type this html URL
  3. you will see your app in play market app
0

To have a solution that works in a best possible way for desktop/Android/mobile non-Android:

HTML:

<a id="play-store-link" href="http://play.google.com/store/apps/details?id=$PACKAGE_NAME">

JS:

if (navigator.userAgent.match(/android/i)) {
    document.getElementById('play-store-link').href = 'market://details?id=$PACKAGE_NAME';
}
1
  • but this don't work with Opera browser
    – KiKMak
    Dec 24, 2019 at 9:59
0

Using the market:// because it is not a web link and won't work on all Android devices

Use this link https://play.app.goo.gl/?link=https://play.google.com/store/apps/details?id=com.myapp

Replace the com.myapp with your app's

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .