我正在尝试创建一个过滤某些特定网址的意图。
我试图捕获的网址是:
- http://host.com/app http://host.com/app
- http://host.com/app/ http://host.com/app/
-
http://host.com/app http://host.com/app?...
-
http://host.com/app/ http://host.com/app/?...
这可以通过
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" android:host="host.com"
android:pathPrefix="/app" android:pathPattern="[app.*]"/>
</intent-filter>
我的问题出现是因为我已经有一个网址:
- http://host.com/appinstall http://host.com/appinstall
我不想尝试打开该网址中的应用程序。
我已经尝试过了
android:pathPattern="[app]
android:pathPattern="[app.*]
android:pathPattern="[app?.*]
android:pathPattern="[app\?.*]
android:pathPattern="[app\\?.*]
android:pathPattern="[app|app?.*]
android:pathPattern="[app|app\?.*]
android:pathPattern="[app|app\\?.*]
android:pathPattern="[nativeapp\z|nativeapp\?.*|nativeapp/.*]"
android:pathPattern="[nativeapp\\z|nativeapp\\?.*|nativeapp/.*]"
但没有一个起作用。
甚至[app\\?.*]
打开/appinstall。
注意:在有人问之前。我有 /appinstall 控制器,因为我正在开发的应用程序开始是 iPhone 应用程序,并且 appInstall url 有很多情况需要处理重定向到应用程序商店的情况。
你需要使用android:path
代替android:pathPrefix
or android:pathPattern
因为这将匹配路径/app
完全并且/appinstall
将被忽略。
<!-- Matches "http://host.com/app" exactly, note that querystring, fragment
identifiers and the trailing slash are not considered part of the path and
are therefore ignored so URLs that will match:
http://host.com/app
http://host.com/app/
http://host.com/app?some=value
http://host.com/app/?some=value
http://host.com/app#fragmentIdentifier
http://host.com/app/#fragmentIdentifier
http://host.com/app?some=value#fragmentIdentifier
http://host.com/app/?some=value#fragmentIdentifier
URLs that will NOT match
http://host.com/app/index.htm
http://host.com/appinstall
http://host.com/appinstall/
http://host.com/app/subdirectory
http://host.com/app/subdirectory/
http://host.com/apple.htm
-->
<data android:scheme="http" android:host="host.com" android:path="/app" />
如果您还想匹配网站的根目录,那么您需要添加一个额外的<data>
元素:
<data android:scheme="http" android:host="host.com" android:path="/" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)