title: Android Asyntask API deprecated
body: <p>Been looking on the internet how to check the current app version of the application and the version available on Play Store. But it was using <code>Asynctask</code> that was deprecated already and I<code>ve been looking alternative way aside from </code>Asynctask<code> been searching on the internet but I couldn</code>t figure out how to do it correctly. Please check the code below:</p>
  <pre><code>private class GetLatestVersion extends AsyncTask&lt;String, String, String&gt; {
      private String latestVersion;
      private ProgressDialog progressDialog;
      private boolean manualCheck;
      GetLatestVersion(boolean manualCheck) {
          this.manualCheck = manualCheck;
      }
      
          String currentVersion = getCurrentVersion();
          //If the versions are not the same
          if(!currentVersion.equals(latestVersion)&amp;&amp;latestVersion!=null){
              final Dialog dialog = new Dialog(activity);
              dialog.setContentView(R.layout.custom_warning_dialog);
              dialog.setCancelable(false);
              Button tryAgain = dialog.findViewById(R.id.bt_positive);
              Button settings = dialog.findViewById(R.id.bt_negative);
              tryAgain.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(&quot;https://play.google.com/store/apps/details?id=&quot;+activity.getPackageName())));
                      dialog.dismiss();
                  }
              });
              settings.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      activity.finish();
                  }
              });
              dialog.show();
          }else {
              if (manualCheck) {
                  Toast.makeText(activity, &quot;No Update Available&quot;, Toast.LENGTH_SHORT).show();
              }
          }
      }
      
      @Override
      protected String doInBackground(String... params) {
          try {
              //It retrieves the latest version by scraping the content of current version from play store at runtime
              latestVersion = Jsoup.connect(&quot;https://play.google.com/store/apps/details?id=&quot; + activity.getPackageName() + &quot;&amp;hl=en&quot;)
                      .timeout(30000)
                      .userAgent(&quot;Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6&quot;)
                      .referrer(&quot;http://www.google.com&quot;)
                      .get()
                      .select(&quot;.hAyfc .htlgb&quot;)
                      .get(7)
                      .ownText();
              return latestVersion;
          } catch (Exception e) {
              return latestVersion;
          }
      }
  }
  </code></pre>