2

我試圖做一些類似於下載管理器的東西,並且我有意圖過濾器的問題。 我捕捉文件下載意圖意圖過濾器是這樣的:Android:pathpattern從瀏覽器攔截文件下載意圖

<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" /> 
    <data android:scheme="https" /> 
    <data android:scheme="ftp" /> 
    <data android:scheme="file" /> 
    <data android:scheme="data" /> 
    <data android:scheme="info" /> 
    <data android:scheme="data" /> 
    <data android:scheme="smb" /> 
    <data android:scheme="nfs" /> 
    <data android:scheme="content" /> 
    <data android:host="*" /> 
    <data android:pathPattern=".*\\.avi" /> 
    <data android:pathPattern=".*\\.mp4" /> 
    .... 
</intent-filter> 

有沒有什麼辦法讓pathpattern樣子*。 *並匹配任何文件類型?

+1

scheme =「data」行在那裏兩次。 你試過了嗎?'? – Buurman

+0

@Buurman該死的,你說得對。有效!非常感謝! – Nookie

+0

我已經將它添加爲正確的答案。你能接受嗎,所以其他人知道這個問題已被回答? – Buurman

回答

2

scheme =「data」行在那裏兩次。

你試過<data android:pathPattern=".*\\..*" />

請注意,您會接受任何文件類型,這可能並非您真正想要的文件類型,原因很多。但任何方式,就是這樣。

+0

此路徑模式非常適合,謝謝! – Nookie