Use Android share intent in Javascript in Chrome?

匿名 (未验证) 提交于 2019-12-03 01:33:01

问题:

I would like to bring up the Android Share menu from Javascript in Chrome for Android. I know that you can launch a specific app from Chrome: https://developers.google.com/chrome/mobile/docs/intents

Is there a way to use href="intent://..." to open the Share menu? This is how it is done in an app: http://developer.android.com/training/sharing/shareaction.html

回答1:

The quick answer is you can't.

I made this sample: http://jsbin.com/AdAPEmu/2 which constructs the Intent as it would appear for Android and Chrome doesn't recognise it, it needs a package to go with it.



回答2:

This article, Triggering a native Share intent on Android from the web, may provide more details about why triggering intents from a web page doesn't currently work as well as it could.

So, yes, apparently you can make this work, but probably only with your own target applications (applications for which you have control over the manifest).



回答3:

There is navigator.share as an experimental technology mentioned in MDN.

Also described more in Google Developers page.

From chrome 61 you can do this, here is demo I found online. I've tested it on latest Android Chrome (on Android Oreo) and it works fine.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!