Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在我的Android应用程序中注册文件扩展名_Android_File_Types_Mime - Fatal编程技术网

在我的Android应用程序中注册文件扩展名

在我的Android应用程序中注册文件扩展名,android,file,types,mime,Android,File,Types,Mime,我有一个文件,其中只包含像“abcdefg”这样的文本,它可以从网上下载或从本地存储卡打开。 我的想法是给这个文件一个独占的扩展名,比如.myfile,然后在我的应用程序中注册.myfile。我在谷歌找到了一些解决方案,但没有一个对我有帮助。文件扩展名似乎无关紧要,只有内容类型才算数。 然而,我认为我必须在我的android清单中注册一个意图过滤器,使用mimeType和pathPattern…[…]。 但我到底要做什么呢 <intent-filter> <a

我有一个文件,其中只包含像“abcdefg”这样的文本,它可以从网上下载或从本地存储卡打开。 我的想法是给这个文件一个独占的扩展名,比如.myfile,然后在我的应用程序中注册.myfile。我在谷歌找到了一些解决方案,但没有一个对我有帮助。文件扩展名似乎无关紧要,只有内容类型才算数。 然而,我认为我必须在我的android清单中注册一个意图过滤器,使用mimeType和pathPattern…[…]。 但我到底要做什么呢

    <intent-filter>

    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.EDIT" />
   <category android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="application/myfile"
android:host="*" 
android:pathPattern=".*\\.myfile"/>
   </intent-filter>

这对我不起作用:(



这很有效!

我想您可能需要将mimeType设置为“应用程序/八位字节流”?好的,我尝试过,但如果选择“打开”,则只有编辑器应用程序
  <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
 <data           android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.myfile"
                android:scheme="file" />