2016-03-10 39 views

回答

2

当在Android浏览器中单击URL时,系统会检查URL路径是否与开发人员包含在AndroidManifest.xml中的任意Intent过滤器匹配(与系统上安装的每个应用程序捆绑在一起的文件)。如果点击的URL和其中一个意图过滤器匹配,则会提示用户处理相关应用程序中的点击,而不是浏览器中的点击。以下是Google日历Android应用清单的旧版本的摘录,其中包含来自其中一个意图过滤器的相关网址;任何匹配这些路径并被点击的URL都将被定向到日历应用。

<data android:scheme="http" android:host="www.google.com" android:pathPrefix="/calendar/event" /> 
<data android:scheme="https" android:host="www.google.com" android:pathPrefix="/calendar/event" /> 
<data android:scheme="http" android:host="www.google.com" android:pathPattern="/calendar/hosted/.*/event" /> 
<data android:scheme="https" android:host="www.google.com" android:pathPattern="/calendar/hosted/.*/event" /> 

基本上,你只需要链接到谷歌定期日历web应用程序,并确保所提供的路径相匹配什么是在谷歌日历应用意图过滤指定。然后,用户可以选择使用应用程序而不是浏览器处理URL(无法强制用户从我知道的网站在Android中打开应用程序)。

有关Intent过滤器如何在Android上工作的更多信息,请参阅check out this article about Intents from the Android documentation.

相关问题