支持从浏览器打开App

时间:2014-06-30 22:18:00

标签: android protocols manifest intentfilter

我的网页有以下链接:

的myapp://www.myapp.com/xxxxxx

期望的效果是从Android设备上的浏览器点击此链接并且 它应该将“myapp”检测为自定义协议,并在设备上直接打开MyApp(如果已安装)。

Launching custom Android application from Android browser / Chrome

Launch custom android application from android browser

我已经研究过这个主题,并在下面发现了类似的问题,

他们提到在AndroidManifest.xml中编辑部分,但他们没有解决问题。

关键是看起来浏览器无法将MyApp识别为自定义协议。

1 个答案:

答案 0 :(得分:0)

如果您想要在手机上重定向到自己应用的链接,请使用以下格式的链接:

android-app::\\<package name>\<URI segments>

在手机上,它将被解析为发送到您的包(app)的URI。在您的应用程序中,您需要做的就是处理这些意图。

当您的应用收到它时,应使用ACTION_VIEW意图过滤器来解析以下URI:

intent:\\<URI segments>

意图是你的计划。简单地做下面的事就行了。

<intent-filter> <action android:name="android.intent.action.VIEW" /> <data android:scheme="intent" /> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter>

对于通过浏览器在网络应用或移动应用上作为着陆页的其他链接: http://www.myapp.com/xxx/yyyy

<data android:host="www.myapp/com" android:scheme="http" android:pathPrefix="xxx />