2013-05-09 40 views
3

我在市場上有一個Android應用程序,我注意到當我發佈新版本時,應用程序可能需要更新才能更新。在應用程序中通知用戶有新版本

我希望的是類似於谷歌Chrome瀏覽器應用程序(可能只是測試版本,它不確定)。

我想要做的是當用戶啓動我的應用程序時,它可以檢查是否有可用的新版本,如果有,只需在底部顯示一條小消息以通知用戶是可供下載的新版本。如果他們點擊它,用戶將直接進入遊戲商店內的應用程序,以便他們可以開始更新。

這是如何完成的?我還沒有設法找到任何東西,我發現了一些與iOS相關的東西,但顯然對我沒有好處。

感謝您提供的任何幫助。

回答

5

當您可以使用Google Play查看您的應用的最新版本時,沒有任何API或服務。

相反,您應該在您的服務器上維護最新的版本代碼,並讓您的應用程序定期對其自己的版本代碼進行檢查。如果服務器上的版本代碼較高,則應用程序需要更新,您可以相應地告訴用戶。

2

如何檢查有應用程序的新版本可用在遊戲商店中,通知用戶使用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/

+0

鏈接下載完整的代碼* *死@vinnet – 2017-10-02 01:14:33

相關問題