执行安装程序

来源:互联网 发布:网络空间安全 研讨会 编辑:程序博客网 时间:2024/06/05 07:50


HttpUtils utils =new HttpUtils();final String target = Environment.getExternalStorageDirectory() + "/update.apk";utils.download(mDownloadURL, target, new RequestCallBack<File>() {    @Override    public void onSuccess(ResponseInfo<File> responseInfo) {        Toast.makeText(SplashActivity.this, "下载成功", Toast.LENGTH_SHORT).show();        Intent intent = new Intent(Intent.ACTION_VIEW);        intent.addCategory(Intent.CATEGORY_DEFAULT);        intent.setDataAndType(Uri.fromFile(responseInfo.result), "application/vnd.android.package-archive");        startActivityForResult(intent, 0);    }    @Override    public void onLoading(long total, long current, boolean isUploading) {        int progress = (int) ((current * 100) / total);        tvProgress.setText("下载进度:" + progress + "%");    }    @Override    public void onFailure(HttpException e, String s) {        Toast.makeText(SplashActivity.this, "下载失败", Toast.LENGTH_SHORT).show();    }});


0 0