如何檢查有應用程序的新版本可用在遊戲商店中,通知用戶使用android中的新版本更新舊應用程序,並顯示是或否讓他們玩遊戲。只需按照說明進行操作,並將附加的代碼放入您的應用程序中即可檢查新版本的應用程序是否可用。此代碼每天檢查應用程序版本,如果在Play Store上有任何新版本更新可用,則會在應用程序啓動時出現更新。
if (newVersion > curVersion) {
/* Post a Handler for the UI to pick up and open the Dialog */
mHandler.post(showUpdate);
}
private Runnable showUpdate = new Runnable(){
public void run(){
new AlertDialog.Builder(MainActivity.this)
.setIcon(R.drawable.ic_launcher)
.setTitle("Update available")
.setMessage("An update for Live Share Tips is available on Play Store.")
.setNegativeButton("Update now", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
easyTracker.send(MapBuilder.createEvent("App update",
"Update now", " ", null).build());
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.appuonline.livesharetips"));
startActivity(intent);
}
})
.setPositiveButton("Later", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked Cancel */
easyTracker.send(MapBuilder.createEvent("Update_Later",
"Update later", " ", null).build());
}
})
.show();
}
};
下載完整的代碼[URL]:http://androidaone.com/11-2014/notify-users-update-app-new-version-available-playstore/
鏈接下載完整的代碼* *死@vinnet – 2017-10-02 01:14:33