安卓Intent-Filter的pathPattern含义是什么?

4
我想创建一个intent-filter,它可以检测像这样的url:
http://192.168.0.xx/playlist/_definst_/iphone.smil/list.m3u8?token=XXXXXXX

我到目前为止已经尝试了这个,但是没有成功。
    <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="*"
            android:pathPattern=".*\\*.m3u8.*"
            android:scheme="http" />
    </intent-filter>

我错过了什么吗?
需要你的帮助。
这对我有用。希望也能帮到其他人。

 <data android:scheme="http" android:host="*"
            android:pathPattern=".*\\.m3u8" />
        <data android:scheme="http" android:host="*"
            android:pathPattern=".*\\..*\\.m3u8" />
        <data android:scheme="http" android:host="*"
            android:pathPattern=".*\\..*\\..*\\..m3u8" />
        <data android:scheme="http" android:host="*"
            android:pathPattern=".*\\..*\\..*\\..*\\.m3u8" />
1个回答

7

请尝试使用以下方法:

<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:scheme="http" />
    <data android:host="*" />
    <data android:mimeType="*/*" />
    <data android:pathPattern="*.*\\.m3u8" />
</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:scheme="http" />
    <data android:host="*" />
    <data android:pathPattern=".*\\.m3u8" />
</intent-filter>

这可以运行:
     <data android:scheme="http" android:host="*"
            android:pathPattern=".*\\.m3u8" />
        <data android:scheme="http" android:host="*"
            android:pathPattern=".*\\..*\\.m3u8" />
        <data android:scheme="http" android:host="*"
            android:pathPattern=".*\\..*\\..*\\..m3u8" />
        <data android:scheme="http" android:host="*"
            android:pathPattern=".*\\..*\\..*\\..*\\.m3u8" />

如果我在iphone和smil之间去掉了点(iphone.smil),它就可以工作了。我认为这个点与此有关。 - Lazy Ninja
1
看这个:[https://dev59.com/1m865IYBdhLWcg3wi_M2#12153391]。它展示了如何处理这种情况。 - Pratik Sharma
在倒数第二个案例中有一个额外的点,..m3u8。 - gauglerb
1
8岁,但是“This worked”应该意味着什么?其他的上面的代码没有起作用吗? - David

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接