Android intent-filter pathPattern

时间:2012-12-11 09:33:51

标签: android android-intent

我想制作一个可以检测这样的网址的意图过滤器:

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 个答案:

答案 0 :(得分:5)

试试这个,

<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" />