无法打开自定义文件扩展名 [英] Cannot open custom file extension

查看:110
本文介绍了无法打开自定义文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我希望支持的文件格式,它只是一个zip,但我将其重命名为.amg,以便我的应用可以读取它。

I have a file format I wish to support, it's just a zip but I've renamed it .amg so my app can read it.

在带姜饼的三星手机上工作正常并打开。

On my samsung phone with gingerbread it works fine and it opens.

在带kitkat的摩托罗拉手机上我得到的是无法打开它。

On my motorola phone with kitkat all I get is can not open it.

我尝试了这里找到的各种解决方案,但似乎都没有用。

I've tried various solutions found here but none seem to work.

通常,我将文件复制到手机的下载文件夹中,然后单击文件。

Typically I copy the file into the download folder on the phone and click the file.

在kitkat上唯一有效的方法是使用Astro File打开文件经理,但我不能强迫别人使用该应用。那么,什么使Astro正常工作却又什么都没有呢?

The only thing that works on kitkat is if I open the file using Astro File Manager, but I can't force that app on people. So what's wrong that makes Astro work but nothing else?

    <activity
        android:name="com.test.StartupActivity"
        android:label="@string/app_name"
        android:theme="@style/backdropTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:host="*" />
            <data android:mimeType="*/*" />
            <data android:scheme="file" />
            <data android:pathPattern=".*\\.amg" />
        </intent-filter>
    </activity>

** * ** * **
如果我在kitkat中使用Astro文件管理器,它似乎可以工作。因此,Astro可以使用,但我尝试过的其他三项功能(包括内置功能)都没有,但是使用姜饼可以正常使用。

** ****** If I use Astro file manager in kitkat it seems to work. So Astro works, the three other ones I've tried including built in one doesn't but with gingerbread it always works.

但是,在我尝试打开文件的过程中,出现以下异常:
存储的块长度无效。

However, on my kitkat when I try and open the file I get the following exception: invalid stored block lengths.

推荐答案

如果您看一下logcat,则在尝试打开电子邮件附件等时,可以看到内容的解析方式。而且您会注意到mimeType是application / octet-stream。请注意,我没有设置pathPattern暗示的方案为file |内容。这是我用于gpx文件的过滤器:

If you take a look at logcat, when attempting to open an email attachment etc you can see how the content is resolved. And you'll notice that the mimeType is application/octet-stream. Notice that I don't set the scheme as that is implied by pathPattern to be file | content. Here is the filters I use for gpx files:

<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/octet-stream"
                android:host="*"
                android:pathPattern=".*\\.gpx" />
        </intent-filter>  

        <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/gpx"
                android:host="*"
                android:pathPattern=".*\\.gpx" />
        </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:host="*"
                android:pathPattern=".*\\.gpx" />
        </intent-filter>

这篇关于无法打开自定义文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆