Opening app in Google Play from a redirect link

2020-05-19 05:27发布

On an Android device, opening a link to an app on Google Play:

https://play.google.com/store/apps/details?id=com.rovio.angrybirds&hl=en

will automatically open the Google Play app by default.

But if you have a link that redirects to the Google Play link, the device opens the browser and then navigates to the browser version of Google Play. Why does this behavior occur?

Unfortunately I cannot use the market:// with Intents which can open Play, I have only control over a web link.

edit: Seems like if I have the link redirect to the market:// url, it can open with Google Play on device.

If link is opened in browser, somehow it is able to redirect to browser version of Google Play despite market:// not being supported in browser.

3条回答
萌系小妹纸
2楼-- · 2020-05-19 05:47

My guess would be that the behaviour is enforced by Google. Redirects would potentially make it easier for developers with bad intentions to install their apps. Google probably checks if the user comes from a redirect, and if yes it doesn't trigger opening of the Play app.

查看更多
狗以群分
3楼-- · 2020-05-19 05:58

Basically, the https://play.... is just a web URL. I suspect the way this works (which is the way standard way Android works) is:

  1. The Market Play App registers to be able to handle URLs of this kind (you can register to handle certain intents, and apply filters to further define what your app will handle).
  2. The app launches the Intent with the https://play... URL
  3. The User is presented with a list of all apps that are registered to handle that intent. SO, the User is able to launch the Play App - the first time (on the phone) the https:\play... intent is launched
  4. When the user chooses which app to fulfill the Intent, if they select Browser (then set it as a default) - the Browser will launch (and will not offer the user the option the next time).
  5. This default can be by: "Settings\Applications\All - Then find the Browser App, select it, and then select Clear Defaults"

You can either call the Play Market directly with the market intent, or use the URL way. I personally use the URL way - even though there are some additional challenges to use it (like handling this particular issue).

查看更多
啃猪蹄的小仙女
4楼-- · 2020-05-19 06:03

Use target="_top"

 <a href="market://details?id={package_name}" target="_top">App</a>
查看更多
登录 后发表回答