2016-05-02 6 views
1

URLが画像(jpg、png、bmp、gif ...)を指しているときだけブラウザで表示できるようにするため、閲覧可能なアプリケーションにファイル拡張子フィルタを追加する

私は android:mimeType="image/*"を試してみましたが、それはインターネットURLでは動作しません、それは直接( file://を使用して)ファイルシステム内の画像を指している場合、それだけで動作します

ファイルでURLをフィルタリングする方法はあります例えばhttp://dmoral.es/assets/image/diffie_hellman.pngのような拡張子?

これは私の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" android:mimeType="image/*" /> 
</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="https" android:mimeType="image/*" /> 

</intent-filter> 

フィルタは、それが閲覧可能なアプリとして作用しない追加して、私は、mimeTypeフィルタを削除する場合には、閲覧可能なアプリとして動作します。

+0

"が、それはインターネットURLでは動作しません" - [MCVE]お知らせください。 – CommonsWare

+0

私は答えを編集しました。 – Grender

+0

これは、あなたの問題を 'android:mimeType = "image/*" 'で示す[mcve]ではありません。 – CommonsWare

答えて

1

最後に、pathPatternと表示されているように、hereを使用して動作させることができました。

<data android:scheme="https" 
       android:host="*" 
       android:pathPattern=".*\\.jpg"/> 
<data android:scheme="https" 
       android:host="*" 
       android:pathPattern=".*\\.jpeg"/> 
<data android:scheme="https" 
       android:host="*" 
       android:pathPattern=".*\\.png"/> 
<data android:scheme="https" 
       android:host="*" 
       android:pathPattern=".*\\.bmp"/> 
<data android:scheme="https" 
       android:host="*" 
       android:pathPattern=".*\\.gif"/> 

(いずれもhttpshttp用)

関連する問題