久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='3no1h'></bdo><ul id='3no1h'></ul>
  • <small id='3no1h'></small><noframes id='3no1h'>

    <tfoot id='3no1h'></tfoot>
    1. <i id='3no1h'><tr id='3no1h'><dt id='3no1h'><q id='3no1h'><span id='3no1h'><b id='3no1h'><form id='3no1h'><ins id='3no1h'></ins><ul id='3no1h'></ul><sub id='3no1h'></sub></form><legend id='3no1h'></legend><bdo id='3no1h'><pre id='3no1h'><center id='3no1h'></center></pre></bdo></b><th id='3no1h'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3no1h'><tfoot id='3no1h'></tfoot><dl id='3no1h'><fieldset id='3no1h'></fieldset></dl></div>
        <legend id='3no1h'><style id='3no1h'><dir id='3no1h'><q id='3no1h'></q></dir></style></legend>
      1. 如果有新版本可用,如何在 Android 應(yīng)用程序中強(qiáng)

        How to force update in Android application if new version is available?(如果有新版本可用,如何在 Android 應(yīng)用程序中強(qiáng)制更新?)

      2. <small id='048NS'></small><noframes id='048NS'>

            <i id='048NS'><tr id='048NS'><dt id='048NS'><q id='048NS'><span id='048NS'><b id='048NS'><form id='048NS'><ins id='048NS'></ins><ul id='048NS'></ul><sub id='048NS'></sub></form><legend id='048NS'></legend><bdo id='048NS'><pre id='048NS'><center id='048NS'></center></pre></bdo></b><th id='048NS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='048NS'><tfoot id='048NS'></tfoot><dl id='048NS'><fieldset id='048NS'></fieldset></dl></div>
              <legend id='048NS'><style id='048NS'><dir id='048NS'><q id='048NS'></q></dir></style></legend>
                <tbody id='048NS'></tbody>

              • <bdo id='048NS'></bdo><ul id='048NS'></ul>
              • <tfoot id='048NS'></tfoot>
                  本文介紹了如果有新版本可用,如何在 Android 應(yīng)用程序中強(qiáng)制更新?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在開發(fā)一個應(yīng)用程序,如果 Play 商店有新版本可用,我想向應(yīng)用程序用戶強(qiáng)制更新,該應(yīng)用程序應(yīng)該向用戶顯示一條對話框消息.

                  I am working on an application I want to give force update to app users if new version available on play store, the app should show a dialog message to user.

                  推薦答案

                  public class ForceUpdateAsync extends AsyncTask<String, String, JSONObject>{
                  
                      private String latestVersion;
                      private String currentVersion;
                      private Context context;
                      public ForceUpdateAsync(String currentVersion, Context context){
                          this.currentVersion = currentVersion;
                          this.context = context;
                      }
                  
                      @Override
                      protected JSONObject doInBackground(String... params) {
                  
                          try {
                               latestVersion = Jsoup.connect("https://play.google.com/store/apps/details?id="+context.getPackageName()+"&hl=en")
                                      .timeout(30000)
                                      .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                                      .referrer("http://www.google.com")
                                      .get()
                                      .select("div[itemprop=softwareVersion]")
                                      .first()
                                       .ownText();
                  
                          } catch (IOException e) {
                              e.printStackTrace();
                          }
                          return new JSONObject();
                      }
                  
                      @Override
                      protected void onPostExecute(JSONObject jsonObject) {
                          if(latestVersion!=null){
                              if(!currentVersion.equalsIgnoreCase(latestVersion)){
                                 // Toast.makeText(context,"update is available.",Toast.LENGTH_LONG).show();
                                  if(!(context instanceof SplashActivity)) {
                                      if(!((Activity)context).isFinishing()){
                                          showForceUpdateDialog();
                                      }
                                  }
                              }
                          }
                          super.onPostExecute(jsonObject);
                      }
                  
                      public void showForceUpdateDialog(){
                          AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(new ContextThemeWrapper(context,
                                  R.style.DialogDark));
                  
                          alertDialogBuilder.setTitle(context.getString(R.string.youAreNotUpdatedTitle));
                          alertDialogBuilder.setMessage(context.getString(R.string.youAreNotUpdatedMessage) + " " + latestVersion + context.getString(R.string.youAreNotUpdatedMessage1));
                          alertDialogBuilder.setCancelable(false);
                          alertDialogBuilder.setPositiveButton(R.string.update, new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int id) {
                                  context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
                                  dialog.cancel();
                              }
                          });
                          alertDialogBuilder.show();
                      }
                  }
                  

                  在 string.xml 中你可以像這樣添加任何你想要的按摩.

                  in string.xml you can add whatever massage you want like this.

                  <string name="youAreNotUpdatedTitle">Update Available</string>
                      <string name="youAreNotUpdatedMessage">A new version of YOUR_APP_NAME is available. Please update to versions</string>
                      <string name="youAreNotUpdatedMessage1">s now</string>
                      <string name="update">Update</string>
                  

                  請記住,您必須在對話框代碼中定義對話框的樣式.

                  remember you have to define the style of your dialog in the dialog code.

                  現(xiàn)在只需在你的基礎(chǔ)活動中編寫 forceUpdate() 函數(shù)并在 onResume() 方法中調(diào)用它,你就完成了!

                  now just write the forceUpdate() function in your base activity and call it inside onResume() method and you are done!!

                  // check version on play store and force update
                      public void forceUpdate(){
                          PackageManager packageManager = this.getPackageManager();
                          PackageInfo packageInfo = null;
                          try {
                              packageInfo =  packageManager.getPackageInfo(getPackageName(),0);
                          } catch (PackageManager.NameNotFoundException e) {
                              e.printStackTrace();
                          }
                          String currentVersion = packageInfo.versionName;
                          new ForceUpdateAsync(currentVersion,BaseActivity.this).execute();
                      }
                  

                  這篇關(guān)于如果有新版本可用,如何在 Android 應(yīng)用程序中強(qiáng)制更新?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動期間獲取當(dāng)前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)
                    <bdo id='e41EA'></bdo><ul id='e41EA'></ul>

                      <tbody id='e41EA'></tbody>

                    <legend id='e41EA'><style id='e41EA'><dir id='e41EA'><q id='e41EA'></q></dir></style></legend>
                  • <small id='e41EA'></small><noframes id='e41EA'>

                    1. <i id='e41EA'><tr id='e41EA'><dt id='e41EA'><q id='e41EA'><span id='e41EA'><b id='e41EA'><form id='e41EA'><ins id='e41EA'></ins><ul id='e41EA'></ul><sub id='e41EA'></sub></form><legend id='e41EA'></legend><bdo id='e41EA'><pre id='e41EA'><center id='e41EA'></center></pre></bdo></b><th id='e41EA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='e41EA'><tfoot id='e41EA'></tfoot><dl id='e41EA'><fieldset id='e41EA'></fieldset></dl></div>
                          • <tfoot id='e41EA'></tfoot>
                            主站蜘蛛池模板: 日韩欧美中文字幕在线观看 | 日韩在线视频免费观看 | 人人爽日日躁夜夜躁尤物 | 激情婷婷 | 亚洲在线视频 | 欧美极品一区二区 | 1000部精品久久久久久久久 | 成年人黄色免费视频 | 国产精品久久av | 欧美精品一区二区三区在线 | 丁香婷婷综合激情五月色 | 精品日韩 | 伊人久久成人 | 欧美网站一区 | 中文字幕国产精品 | 国产午夜av片 | 欧美国产精品 | 久久成人免费 | 久久久成 | 天天干夜夜操视频 | 久久久91精品国产一区二区精品 | 亚洲精品一区中文字幕乱码 | 国产小视频在线 | 中文字幕精品一区 | 日韩中文一区二区 | 亚洲精品久久久久久久久久久久久 | 在线观看亚洲 | 国产美女精品视频 | 91精品国产乱码久久久 | 亚洲一区二区三区在线视频 | 91精品久久久久久久久久小网站 | 成人水多啪啪片 | 亚洲精彩视频在线观看 | 午夜成人在线视频 | 综合久久综合久久 | 国产精品久久久久久久久久免费看 | 日韩中文字幕在线观看视频 | 国产高清视频在线 | 盗摄精品av一区二区三区 | 波多野结衣在线观看一区二区三区 | 亚洲 中文 欧美 日韩 在线观看 |