1

Following code used:

public class ForceUpdateAsync extends AsyncTask<String, String,
   JSONObject> {
               VersionListener mWsCallerVersionListener;
               private String latestVersion;
               private String currentVersion;
               private Context context;
           
               public ForceUpdateAsync(String currentVersion, Context context, VersionListener callback) {
                   this.currentVersion = currentVersion;
                   this.context = context;
                   mWsCallerVersionListener = callback;
               }
           
               @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.hAyfc:nth-child(4) > span:nth-child(2) > div:nth-child(1) > span:nth-child(1)")
                               .first()
                               .ownText();
                       Log.e("latestversion", "---" + latestVersion);
           
                   } catch (Exception e) {
                       e.printStackTrace();
                       mWsCallerVersionListener.onGetResponse(false);
                   }
                   return new JSONObject();
               }
           
               @Override
               protected void onPostExecute(JSONObject jsonObject) {
                   if (latestVersion != null) {
                       if (Float.parseFloat(currentVersion)<Float.parseFloat(latestVersion)) {
           
           
                           mWsCallerVersionListener.onGetResponse(true);
                       } else {
           
                           mWsCallerVersionListener.onGetResponse(false);
                       }
                   } else {
           
                       mWsCallerVersionListener.onGetResponse(false);
                   }
                   super.onPostExecute(jsonObject);
               }
           }

Getting following exception:

Attempt to invoke virtual method 'java.lang.String org.jsoup.nodes.Element.ownText()' on a null object reference

my assumption is that issue occurred due to updated html of play store. how I can get latest version of Play-store build?

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Use the same method you've used when you wrote your current code and your current selector to find the new selector. – TDG Jun 03 '22 at 08:57
  • Can you please share code with me because above shared method returns exception. that exception occurred due to updated html of play console please check following link https://play.google.com/store/apps/details?id=com.VectorUpGames.TallManRun jsoup read html now updated html for that please suggest me how I can get updated version. – Nitish Mehta Jun 08 '22 at 10:27
  • Check link following issue but did't get any solution regarding this https://stackoverflow.com/questions/34309564/how-to-get-app-market-version-information-from-google-play-store Solution until May 2022 (NO LONGER WORKS) – Nitish Mehta Jun 09 '22 at 10:52

0 Answers0