2012-11-17 5 views
9

私のアプリケーションを使ってカスタム拡張機能を使ってファイルを開く必要があります。私はファイルが私のSDカードにあるときにインテントフィルターを使用してこれを行うことができます。ファイルがGmailの添付ファイルとして送信されている場合は、[ダウンロード]と[プレビュー]ボタンも表示されます。しかし、ダウンロード/プレビューボタンをクリックすると、メッセージが届きました。"申し訳ありませんが、添付ファイルをダウンロードできませんでした"Android - 自分のアプリケーションでGmail添付ファイルを開く

私はこれが私のアプリの問題だと思っていました。しかし、私はランダムなアイデアを持っていて、私の電話に "Download All Files"アプリをインストールしました。 https://play.google.com/store/apps/details?id=com.hwkrbbt.downloadall&hl=en 次に、Gmailでダウンロードボタンをクリックすると、ファイルをダウンロードするための[すべてのファイルをダウンロード]と[私のアプリケーション]の両方が表示されます。私は私のアプリを選んだ、そしてすべてがうまくいく!!

これはセキュリティ上の問題ですか? これらは私のインテントフィルタです:

<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:mimeType="*/*" /> 
     <data android:scheme="content" android:host="*" 
      android:pathPattern=".*\\.ate" /> 
     <data android:scheme="file" android:host="*" 
      android:pathPattern=".*\\.ate" /> 
    </intent-filter> 
    <intent-filter> 
     <action android:name="android.intent.action.VIEW" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <data android:mimeType="application/*" host="*" android:pathPattern=".*.ate" android:scheme="content" /> 
    </intent-filter> 

編集:ここでは完全な活性タグです。

<activity android:name=".TestApp" 
       android:label="@string/app_name" 
       android:configChanges="orientation|keyboardHidden" 
       android:launchMode="singleTask"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
     <intent-filter> 
      <action android:name="com.TestApp.TestApp.NOTIFICATION" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
     <!-- Opening .ate file start --> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="file" /> 
      <data android:host="*" /> 
      <data android:pathPattern=".*\\.ate" /> 
      </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:mimeType="*/*" /> 
     <data android:scheme="content" android:host="*" 
      android:pathPattern=".*\\.ate" /> 
     <data android:scheme="file" android:host="*" 
      android:pathPattern=".*\\.ate" /> 
    </intent-filter> 
    <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=".*\\.ate" android:mimeType="application/octet-stream"/> 
     <data android:scheme="content" android:pathPattern=".*\\.ate" android:mimeType="application/octet-stream"/> 
     </intent-filter> 
     <!-- Opening .ate file end --> 
    </activity> 
+0

は、あなたが試してみました**アンドロイドMIMEタイプのアプリケーションで、両方のコンテンツおよびファイル・スキームの種類が必要ですか? –

答えて

9

私は自分自身をそれを考え出したので、私は念の誰かの出会いで、この奇妙な問題を解決を掲示しています。ホスト= "Gmailの-LS" **:

インテントフィルタは/ octetstream

<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=".*\\.inform" android:mimeType="application/octet-stream"/> 
<data android:scheme="content" android:pathPattern=".*\\.inform" android:mimeType="application/octet-stream"/> 

+0

こんにちはBlue、のタグを完全に共有できますか? – Giuseppe

+0

こんにちはジュゼッペ、私の質問を確認してください。私は編集を追加しました。 – Manju

+3

私はこの解決策を試してみましたが、うまくいきましたが、 'pathPattern'が無視されるので誤解を招きます。 'pathPattern'属性はフィルタに' scheme'属性と 'host'属性が指定されていない限り無視されます(あなたの答えには' host'属性がありません)。 'pathPattern'属性については、[documentation](http://developer.android.com/guide/topics/manifest/data-element.html)を参照してください。私も実際にこれを見てきました。インテントフィルターは、指定されたファイル拡張子を持つ添付ファイルだけでなく、すべての添付ファイルを処理します。 –

関連する問題