2017-08-05 114 views
1

我有一个应用程序,我允许用户备份数据,并希望他们能够通过文件管理器,GMail点击备份文件,和下载系统应用程序。Android:文件扩展名意图过滤器无法与GMail/Downloads应用程序正常工作

我在清单文件中定义了以下意图...

 <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> 

以上的作品,如果我点击从文件管理器.sbu文件,但不能从下载的Gmail或Google列表。我确实读过我需要mimeType才能使内容方案正常工作,但是当我将mimeType定义为*/*application/octet-stream时,该功能甚至在文件管理器中停止工作。

我在做什么不正确?第一次写入文件时是否需要设置任何设置?你最好如何处理我的情况。

回答

0

我通过将内容放入其自己的意图过滤器组以及文件数据方案来实现它,它们都具有MIME类型的应用程序/八位字节流。

 <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

这将打开任何和所有文件的Gmail附件。不只是sbu,但abc,xyz等。我无法弄清楚如何使它过滤Gmail文件扩展名? –

相关问题