FinalHttp http = new FinalHttp();
// apkurl 下载的网络地址
// target 保存文件的目标地址
// AjaxCallBack 异步回调的对象
http.download(apkurl, Environment.getExternalStorageDirectory()
+ "/mobilesafev2.0.apk", new AjaxCallBack<File>() {//下载失败回调public void onFailure(Throwable t, String strMsg) {super.onFailure(t, strMsg);Toast.makeText(SplashActivity.this, "下载失败", 0).show();}/***下载过程中回调* count 下载文件使用的总长度(时间:毫秒) current 当前下载的进度(时间:毫秒)*/public void onLoading(long count, long current) {super.onLoading(count, current);int cunrr = (int) ((current * 100) / count);//更新下载进度tv_progress.setText(cunrr + "%");}//下载成功回调public void onSuccess(File t) {super.onSuccess(t);Toast.makeText(SplashActivity.this,"下载成功,文件保存在了" + t.getPath(), 0).show();// 下载完成后自动安装intallApp(t);}// 下载完成后自动安装private void intallApp(File t) {// <action android:name="android.intent.action.VIEW" />// <category// android:name="android.intent.category.DEFAULT" />// <data android:scheme="content" />// <data android:scheme="file" />// <data// android:mimeType="application/vnd.android.package-archive"// />//启动安装Intent intent = new Intent();intent.setAction("android.intent.action.VIEW");intent.addCategory("android.intent.category.DEFAULT");intent.setDataAndType(Uri.fromFile(t),"application/vnd.android.package-archive");startActivity(intent);}});