Android无法打开文件 [英] Android can't open file

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

问题描述

我正在尝试通过DownloadManager从服务器下载一个apk文件:

I'm trying to download an apk file from server via DownloadManager:

dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
        request.setMimeType("application/vnd.android.package-archive");
        request.allowScanningByMediaScanner();
        enqueue = dm.enqueue(request);

当apk下载并按下它时,我收到无法打开文件信息 ,

但是如果我通过浏览器而不是DownloadManger 下载该apk:

When the apk is downloaded and I press it I'm getting "can't open file message",
But if I download that apk via Browser instead of DownloadManger:

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);

该apk可以正常使用。

设备为未知来源打开,版本为4.1.2

The apk works fine.
The device is open for "Unknown sources" and it's version is 4.1.2

我做错了什么?

推荐答案

尝试将apk文件保存到本地存储,然后使用直接文件URI打开它

try saving the apk file to your local storage and then opening it using a direct file URI

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

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