简体   繁体   中英

Opening .zip files with intent-filter on Galaxy S5

I'm trying to open a zip file in an app I'm writing, but when I browse the file in My Files on a Galaxy S5, My Files unzips the file instead of opening the app.

If I change the extension to .upgradezip, the app has no problem opening with the specified file passed to it, but My Files seems to ignore the intent filter entirely and tries to unzip the file, specifically, when the extension is .zip

Other devices, including LG tablets, can open the .zip files using my app just fine, using the same manifest as on the Galaxy S5.

Thoughts? Here's the relevant info from my manifest, I've supported both zip and upgradezip in the interim, but it'd be great for all devices to use zip.

        <intent-filter>
            <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:scheme="content" android:pathPattern=".*\\.upgradezip" android:mimeType="application/octet-stream"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:host="" android:scheme="file" android:mimeType="*/*" android:pathPattern=".*\\.upgradezip"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/octet-stream" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/zip" />
        </intent-filter>

Write your own file browser. When you call an external program to do something, especially an external program that can change by device, you have absolutely zero control over how it works. It thinks the best thing to do when you tap on a zip is to open it. You can't stop it from doing that. So if you really don't want it to do that, don't use that app. The only way to force it not to is to write your own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM