Cannot open custom file extension
Asked Answered
P

1

9

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.

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.

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>

** [EDIT] ****** 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.

Plymouth answered 13/2, 2014 at 3:23 Comment(6)
I am thinking it is the pathPattern. On the Motorola does the path with the "AMG" files contain a period in it? That may cause an issue. Take a look at this example of the hoops the guy goes through to do something similar to yourself: github.com/bpellin/keepassdroid/blob/master/AndroidManifest.xmlCollazo
Maybe can help you: #7031332Pawl
I've already tried that :( Surely this is a common thing? so why are there so many solutions and not one by anything official that I can find?. also the path is just /storage/sdcard0/download/file.amgPlymouth
This question is still without an approved answer, but it might help you a) figure out a solution, b) understand the problem better: Register Activity To Open Any File With Certain Extension. It recently had a bounty.Roxy
#4675757 check thisSanorasans
I am not sure what you mean here exactly -- "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."..Explain it a bit clearly.. and for your next question " I get the following exception: invalid stored block lengths." --- This is mainly happens when your file is corrupted, user this same file on other device and let me know whether it works?Puce
T
1

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>
Tongue answered 22/7, 2014 at 13:51 Comment(2)
Thanks! MimeType with extension works well on all files!Evangelina
Any idea how to send launch parameters to the app/or how it is sent? I'd like to load the url from where the app was launched (load project by clicking project file).Tymes

© 2022 - 2024 — McMap. All rights reserved.