【发布时间】:2013-05-05 15:33:54
【问题描述】:
在我的应用程序中,我想处理使用以下模式的链接:
scheme://host/folder1/folder2/folder3/folder4/article
我通过以下方式让它暂时工作:
<intent-filter>
<data android:scheme="http" />
<data android:host="www.laprensa.com.ni" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
但是,正如您可能想象的那样,它会打开任何以 scheme://host 开头的链接,我想确保我只选择那些具有上述模式的链接,其中页面是主机内的 4 个文件夹。
另一个小问题是文件夹名称永远不会相同,因此我不能简单地使用android:path。还值得注意的是,android:pathPrefix 不一样,因为前三个文件夹与日期相关。
例如,网址的结构如下:
scheme://host/year/month/day/articleType/article
我一直在阅读有关如何使用 android:pathPattern 的文档和问题,但我真的不明白我应该输入什么。
有什么想法吗?
谢谢!
编辑
根据建议,我尝试了:
android:pathPattern="/.*/.*/.*/.*/.*"
每个 '.*' 代表一个文件夹,但似乎仍会选择其他不是文章的 URL。例如,这里有两个不同的 url:
我要处理的网址:
http://www.laprensa.com.ni/2013/05/10/vida/145996-lionel-richie-defiende-a
我不想处理的网址
http://www.laprensa.com.ni/2013/05/10/vida/
我想这里的问题是它们都有相同数量的级别,唯一的区别是一个实际上在最后一个 '/' 之后有一些东西,我可以尝试其他任何想法吗?我确实尝试再添加一个'/.*',但它完全停止工作并且应用程序停止处理任何链接期间:(
【问题讨论】:
-
尝试使用
-
daniel_c05 你最后是怎么解决的?
标签: android android-intent path intentfilter