我想弄清楚的意圖過濾器,我需要爲:意圖過濾器捕捉意圖查看* .EXT文件
查看文件或內容有* .npk擴展
我讀有關意向過濾器的stackoverflow文章的負載,但仍然不明白我錯過了什麼。
例如,當這是我的意圖過濾器,我期望它捕捉帶有「* .npk」擴展名的文件。我知道與模式的錯誤,所以我爲了趕路徑,那裏是.npk前0-4點添加多個數據線:
<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="file" android:pathPattern=".*\\.npk" />
<data android:scheme="file" android:pathPattern=".*\\..*\\.npk" />
<data android:scheme="file" android:pathPattern=".*\\..*\\..*\\.npk" />
<data android:scheme="file" android:pathPattern=".*\\..*\\..*\\..*\\.npk" />
<data android:scheme="file" android:pathPattern=".*\\..*\\..*\\..*\\..*\\.npk" />
</intent-filter>
當我打開從總指揮官文件app它的工作原理,並開始我的活動如預期(BTW這個工程即使我只有一個pathPattern =,所以也許提到的錯誤是固定在棒棒糖「* \\ NPK。」):
{act=android.intent.action.VIEW dat=file:///storage/emulated/0/Android/data/com.fletech.smartbaby.android.pro/files/npk/animal-water-he.npk typ=application/octet-stream flg=0x10000000 cmp=com.fletech.smartbaby.android/.CategorySliderActivity}
不過,我可以」使它從Dropbox應用程序工作。這是來自logcat的「捕獲」意圖。爲了捕獲它,我添加了android:mimeType =「*/*」,所以我可以選擇我的應用程序,現在每個文件(也是.jpg)都想打開我的應用程序。
{act=android.intent.action.VIEW dat=file:///storage/emulated/0/Android/data/com.dropbox.android/files/u123456/scratch/apk/nature_0.npk typ=application/octet-stream flg=0x10000003 cmp=com.fletech.smartbaby.android/.CategorySliderActivity (has extras)}
我不明白爲什麼上面的過濾器沒有抓住這個意圖。唯一的區別我看到總指揮官的意圖和收件箱意圖之間的標誌,額外的應該沒有區別恕我直言,並且在文件擴展名之前的路徑中有2個vs 4個點,但我的意圖過濾器應該小心的。
注:我正在開發和測試棒棒糖,但我希望它可以在api 9+上工作。