public void downLoadApk() { final ProgressDialog pd = new ProgressDialog(this); pd.setTitle("正在下载..."); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.show(); FinalHttp fh = new FinalHttp(); fh.download(updateInfo.getApkurl(), "/sdcard/temp.apk", new AjaxCallBack<File>() { public void onSuccess(File t) { Log.i(TAG, "下载成功,安装apk"); pd.dismiss(); 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); finish(); super.onSuccess(t); } public void onLoading(long count, long current) { pd.setMax((int) count); pd.setProgress((int) current); super.onLoading(count, current); } }); }
原文地址:http://blog.csdn.net/feecooling/article/details/38428027