意图过滤器的路径模式

时间:2013-03-06 10:39:41

标签: android path intentfilter

我想点击网址启动Android应用程序(可能是电子邮件或短信)。

如何为这两个URL编写不同的路径模式?

  • http://www.hostname.com/folder1/file.ext
  • http://www.hostname.com/folder1/folder2/file.ext

我想仅从第一个网址启动我的活动,而不是第二个网址。目前我正在使用此intent-filter,但它正在使用这两个网址启动我的应用。

<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="www.hostname.com"
        android:pathPattern=".*\\/folder1/*"
        android:scheme="http" />
</intent-filter>

1 个答案:

答案 0 :(得分:0)

尝试以下代码

<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="www.hostname.com"
        android:pathPrefix="/folder1"
        android:scheme="http" />
</intent-filter>
相关问题