【问题标题】:android parse error parsing packageandroid解析错误解析包
【发布时间】:2014-12-04 15:24:03
【问题描述】:

我正在开发内部服务器的自动更新。
下载效果很好,但是当我尝试安装下载的 apk 时,我得到:“解​​析错误,解析包问题”。

private BroadcastReceiver mDownloadReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
            long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
            Log.i(VERSION_LOG_TAG, "received download id: " + downloadId);

            DownloadManager.Query query = new DownloadManager.Query();
            query.setFilterById(enqueue);
            Cursor cursor = dm.query(query);
            if (cursor.moveToFirst()) {
                int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);

                if (DownloadManager.STATUS_SUCCESSFUL == cursor.getInt(columnIndex)) {
                    String uriString = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
                    Log.i(VERSION_LOG_TAG, uriString);

                    Intent installIntent = new Intent(Intent.ACTION_VIEW);
                    File apk = new File(Uri.parse(uriString).getPath());
                    installIntent.setDataAndType(Uri.fromFile(apk), "application/vnd.android.package-archive");
                    startActivity(installIntent);
                }else{
                    Log.e(VERSION_LOG_TAG, "download failed");
                }
            }
        }
    }
};

我认为是因为网址:content://downloads/my_downloads/13 我做错了什么?

【问题讨论】:

标签: android download installation


【解决方案1】:

只需尝试从文件管理器应用程序打开下载的文件,或者您可以下载 ex 文件资源管理器,因为它不会直接从应用程序内访问文件 url,因此它不会给出解析错误

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-24
    • 1970-01-01
    • 1970-01-01
    • 2011-08-13
    • 2016-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多