2017-08-05 2 views
1

Ich habe eine App, wo ich Benutzern erlauben, Daten zu sichern und wollen sie in der Lage sein, auf die Backup-Datei über einen Datei-Manager, GMail, und die Downloads System App.Android: File Extension Intent Filter funktioniert nicht richtig mit GMail/Downloads App

ich folgende Absicht in meiner Manifest-Datei ...

 <intent-filter 
      android:label="Simple Backup File" 
      android:priority="999" > 

      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.OPENABLE" /> 

      <data 
       android:scheme="http" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="https" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="ftp" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="ftps" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="content" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="file" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 
     </intent-filter> 

Die oben genannten Arbeiten definiert haben, wenn ich von einem Dateimanager auf die .sbu Datei klicken, aber nicht von GMail oder der Liste der Downloads. Ich habe gelesen, dass ich einen mimeType brauche, um das Inhaltsschema zum Laufen zu bringen, aber wenn ich einen MIMEType als */* oder application/octet-stream definiere, funktioniert die Funktionalität sogar innerhalb eines Dateimanagers nicht mehr.

Was mache ich falsch? Muss ich beim ersten Schreiben der Datei Einstellungen vornehmen? Wie würdest du am besten mit meiner Situation umgehen?

Antwort

0

Ich habe es funktioniert, indem ich Inhalt in seine eigene Intent-Filter-Gruppe zusammen mit einem Datei-Daten-Schema, beide mit einem Mime-Typ der Anwendung/Oktett-Stream.

 <intent-filter android:priority="999" > 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.OPENABLE" /> 

      <data 
       android:scheme="http" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="https" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="ftp" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="ftps" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="file" 
       android:host="*" 
       android:pathPattern=".*\\.sbu" /> 
     </intent-filter> 

     <intent-filter android:priority="999" > 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.OPENABLE" /> 

      <data 
       android:scheme="file" 
       android:mimeType="application/octet-stream" 
       android:pathPattern=".*\\.sbu" /> 

      <data 
       android:scheme="content" 
       android:mimeType="application/octet-stream" 
       android:pathPattern=".*\\.sbu" /> 
     </intent-filter> 
+0

Dies öffnet alle Datei-Gmail-Anhänge. Nicht nur sbu, sondern auch abc, xyz usw. Ich kann nicht herausfinden, wie man eine Gmail-Dateierweiterung filtert. –

Verwandte Themen