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?

slybloty
  • 560
  • 3
  • 10
  • 27
  • 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?) – Matthew Read Apr 23 '12 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 '12 at 23:26
  • Try replacing http with https. It may look dumb, but try it. – iOS Apr 24 '12 at 13:25
  • @SachinShekhar I used both http and https. Even market. And the same result. – slybloty Apr 24 '12 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 '12 at 13:43
  • Did you get solution for this? – VVB Aug 03 '17 at 09:41

7 Answers7

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.

iOS
  • 12,381
  • 13
  • 63
  • 103
  • Interesting that this way works. It directs to the market place properly. Thanks. – slybloty Apr 24 '12 at 14:36
  • 3
    This'll only work on the Android device. Trying this in a desktop browser won't work. – ale Apr 24 '12 at 15:20
  • @AlEverett Unless there's a market protocol handler in desktop browser to insert domain and host. :) – iOS Apr 24 '12 at 15:24
  • In fact, it doesn't work even in Android web browsers. Its intended to use in app development. – iOS Apr 24 '12 at 15:26
  • Then if this is an app development question it's in the wrong place. – ale Apr 24 '12 at 15:30
  • @AlEverett Can't be said as asker didn't mention that. Android has system-wide protocol handler for this. So, I believe, it can be used with Tasker etc too. – iOS Apr 24 '12 at 15:36
  • Initially, I assumed different thing (see my comments on question). Then, I got the clue from asker's comment on other question: The link is accessed from device. – iOS Apr 24 '12 at 15:40
  • @SachinShekhar The link is stored in a QR code as well as redirected form a website. It is accessed through a QR code reader from a device. Therefore, I don't believe it has anything with development. – slybloty Apr 24 '12 at 17:23
  • @slybloty Thanks for the clarification. I was curious as you didn't mention development anywhere. – iOS Apr 25 '12 at 03:18
  • And, it has opened new usage domain for me. Thanks again.. :) – iOS Apr 25 '12 at 03:23
  • This only works for Android devices. How can you make it work for both mobile and desktop browsers regardless of operating system, given that when on Android I want to open the Google Play store app and not the web browser? –  Oct 07 '15 at 09:26
  • To combine best of both worlds, set URL of the link to http://play.google.com/store/apps/details?id=<package_name> and then change it in JS if on Android - see my answer below http://android.stackexchange.com/a/164307/165570 – jakub.g Dec 13 '16 at 14:14
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);
}
slybloty
  • 560
  • 3
  • 10
  • 27
beka
  • 71
  • 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 04 '13 at 08: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.

Nova
  • 3,369
  • 6
  • 30
  • 57
  • 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 '12 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

Sepero
  • 707
  • 2
  • 9
  • 13
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';
}
jakub.g
  • 133
  • 1
  • 9
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

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
Sid
  • 4,176
  • 9
  • 35
  • 60
moux
  • 11