使用 IntentFilter 处理 HTTP Url
HTTP Url handling with IntentFilter
我已经阅读了有关此主题的其他一些问题,但没有人回答我的问题。
我的情况如下:用户在任何应用程序(如 Facebook、Gmail...)上点击 URL,此 URL 包含 http:\www.italiansubs.net/forum/...
和一些其他参数.我希望该应用程序能够处理特定的 link,因此,根据网站上的一些其他问题,我尝试了这个:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="italiansubs.net" android:scheme="www" />
<data android:host="italiansubs.net" android:scheme="http" />
</intent-filter>
但每次我使用该语法单击 URL 时,浏览器都会出现并打开 link。我需要感知link,然后让应用程序做一些其他操作,但我的应用程序没有显示为可能的选择。
我怎样才能让这段代码起作用?
谢谢。
host
值是出现在 URL 中的完整域名。这可能意味着您需要一些 <data>
元素来处理 scheme
(如果链接可能使用 http
或 https
)和 host
(foo.com
、www.foo.com
、wow.subdomains.are.cool.foo.com
、等等)。
我已经阅读了有关此主题的其他一些问题,但没有人回答我的问题。
我的情况如下:用户在任何应用程序(如 Facebook、Gmail...)上点击 URL,此 URL 包含 http:\www.italiansubs.net/forum/...
和一些其他参数.我希望该应用程序能够处理特定的 link,因此,根据网站上的一些其他问题,我尝试了这个:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="italiansubs.net" android:scheme="www" />
<data android:host="italiansubs.net" android:scheme="http" />
</intent-filter>
但每次我使用该语法单击 URL 时,浏览器都会出现并打开 link。我需要感知link,然后让应用程序做一些其他操作,但我的应用程序没有显示为可能的选择。
我怎样才能让这段代码起作用?
谢谢。
host
值是出现在 URL 中的完整域名。这可能意味着您需要一些 <data>
元素来处理 scheme
(如果链接可能使用 http
或 https
)和 host
(foo.com
、www.foo.com
、wow.subdomains.are.cool.foo.com
、等等)。