首页 > 代码库 > 下载apk文件

下载apk文件

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 onl oading(long count, long current)
		{
			pd.setMax((int) count);
			pd.setProgress((int) current);
			super.onLoading(count, current);
		}
	});
}