原始出處 、作者資訊和本宣告。否則將追究法律責任。
版本更新
看看我們要用到哪些技術
1 自定義通知欄
3 asynctask
4 重新整理通知欄中的進度條
5 執行 apk安裝的隱士意圖
6 toast
7簽名(安裝時系統會自動檢測簽名是否一致)
8獲得服務端和客戶端的版本號
上**
(4) 隱士意圖來安裝
首先別忘了寫許可權!!!!!超愛忘得東西 恨死它了
android:name="android.permission.internet">
android:name="android.permission.write_external_storage">
android:name="android.permission.install_packages">
private runnable mrun;
private notificationmanager mnotificationmanager;
private notification notification;
private remoteviews remoteviews;
private int count;
private int loadversion;
private int version;
private void upgrade()
catch (namenotfoundexception e1)
//伺服器端通過get 得到json
//自定義通知的方法 在上上篇的博文中 這裡不做太多的解釋
private void sendnotification()
remoteviews.setprogressbar(r.id.
progressbar1, 100, 100,
false);
remoteviews.settextviewtext(r.id.
textview1, 100+"%");
mnotificationmanager.notify(8888, notification);
toast.maketext(welcome.
this, "download over", toast. }}};
handler.postdelayed(mrun, 300);
update_asynctask mupdate_asynctask=
new update_asynctask();
mupdate_asynctask.execute(
newurl("")); }
catch (malformedurlexception e) }
class update_asynctask
extends asynctask
inputstream is = con.getinputstream();
system.
out.println(contentlength);
file file=
new file(constant.
apk_file_path);
if(!file.exists())
fileoutputstream out=
new fileoutputstream(file);
int current = 0;
int x=0;
bytearr=
new byte[1024];
while ( (current = is.read(arr)) != -1 )
is.close();
} catch (exception e)
return null; }
} /*
* 此類為系統安裝的隱士意圖 */
public class install
extends activity }
效果如下
本文出自 「
美麗的奇葩
」 部落格,請務必保留此出處
app自動更新 android
public string getvesionname context context catch namenotfoundexception e return versionname 複製 更新以及安裝程式需要的許可權,在androidmanifest.xml中新增 複製 獲取apk的versio...
iOS 如何更新APP
app更新的流程思想 得到當前版本號currentversion,將currentversion與最近的版本號latestversion進行比較,若當前currentversion較小,進行更新操作。獲取當前app的版本號 nsstring currentversion nsbundle mainb...
android7 0適配 app版本更新
android8.0適配鏈結 以下 可以直接使用 第一步,配置清單檔案 com.hibabypsy.provider android exported false android granturipermissions true xml file paths 中紅色部分為包名,替換成自己的即可。藍色...