Android版本更新實(shí)例詳解
更新時(shí)間:2017年06月23日 14:15:56 投稿:lqh
這篇文章主要介紹了Android版本更新實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
Android版本更新實(shí)例詳解
1、導(dǎo)入xutils的jar包

2、在AndroidManifest.xml中添加權(quán)限
3、選擇下載的路徑,和下載apk文件的網(wǎng)址
private String url=”http://www.oschina.NET/uploads/osc-Android-v2.6.4-release.apk”; private String sdPath = “/sdcard/” + System.currentTimeMillis() + “yuyin.apk”;
4、當(dāng)點(diǎn)擊按鈕的時(shí)候進(jìn)行下載
HttpUtils httpUtils=new HttpUtils();
//參數(shù)一:下載的路徑 參數(shù)二:下載到sdpath的路徑 參數(shù)三:
httpUtils.download(url, sdPath, true, new RequestCallBack() {
@Override
public void onSuccess(ResponseInfo<File> arg0) {
mBtn.setText("下載完成");
//路徑
String path = arg0.result.getPath();
File file = new File(path);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
}
@Override
public void onFailure(HttpException arg0, String arg1) {
mBtn.setText("下載失敗");
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
// TODO Auto-generated method stub
super.onLoading(total, current, isUploading);
mBtn.setText("正在下載.....");
}
@Override
public void onStart() {
super.onStart();
mBtn.setText("開始下載");
}
});
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Android LuBan與Compressor圖片壓縮方式
本篇文章主要介紹了Android LuBan與Compressor圖片壓縮方式,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-04-04
Android實(shí)現(xiàn)用戶登錄記住密碼功能
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)用戶登錄記住密碼功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05
Android中Property Animation屬性動畫編寫的實(shí)例教程
這篇文章主要介紹了Android中Property Animation屬性動畫編寫的實(shí)例教程,Property Animation對于動畫幀的操控十分強(qiáng)大,需要的朋友可以參考下2016-04-04
Android中的Intent Filter匹配規(guī)則簡介
這篇文章主要為大家詳細(xì)介紹了Android中的Intent Filter匹配規(guī)則,感興趣的小伙伴們可以參考一下2016-04-04

