简体   繁体   English

在Galaxy S5上使用意图过滤器打开.zip文件

[英]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. 我正在尝试在正在编写的应用程序中打开一个zip文件,但是当我在Galaxy S5上的“我的文件”中浏览该文件时,“我的文件”会解压缩该文件,而不是打开该应用程序。

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 如果我将扩展名更改为.upgradezip,则应用程序打开并传递指定文件时没有问题,但是“我的文件”似乎完全忽略了意图过滤器,并尝试将文件解压缩,特别是当扩展名为.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. 其他设备,包括LG平板电脑,都可以使用我的应用程序(与Galaxy S5上的清单相同)打开.zip文件。

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. 这是我清单中的相关信息,在此期间,我同时支持zip和upgradezip,但是对于所有设备而言,使用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. 强制不要这样做的唯一方法是编写自己的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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