开发者社区> 问答> 正文

安卓apk下载失败

下面是我的下载代码:
这个程序为啥直接跳到下载失败了?

 public void onClick(DialogInterface dialog, int which) {
 //下载新版本的apk,替换安装
 HttpUtils httpUtils = new HttpUtils();
 final File file = new File(Environment.getExternalStorageDirectory(),"xx.apk");
 httpUtils.download(info.downloadurl, file.getAbsolutePath(), false, new RequestCallBack() {
                @Override
                public void onSuccess(ResponseInfo<File> arg0) {
                    ToastUtils.show(SplashActivity.this, "下载成功");
                    //替换安装apk
                    Intent intent  = new Intent();
                    intent.setAction("android.intnet.action.VIEW");
                    intent.addCategory("android.intent.actegory.DEFAULT");
                    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
                    startActivity(intent);
                }

                @Override
                public void onFailure(HttpException arg0, String arg1) {
                    ToastUtils.show(SplashActivity.this, "下载失败");
                }
            log里面打印的错误是:`09-18 17:21:39.442: W/InputMethodManagerService(1005): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@b6645758 attribute=null`

展开
收起
爵霸 2016-06-03 10:21:44 2340 0
1 条回答
写回答
取消 提交回答
  • info.downloadurl
    file.getAbsolutePath()i
    调试输出下这两个,看下路径是否合法、存在,url是否正确。在浏览器中用你的url下载看看。

    2019-07-17 19:26:07
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载