Read complete story

How to get your app’s version name from google play store

There are several situations where you may need the current version of your app from google play store to perform certain tasks like comparing it with the app version present in your device and creating an alert dialogue to update the app if the app version is lesser than play store version.

To do this you can use JSOUP library. This library actually provides a very convenient way to parse the HTML and provide you the current version of your app from play store.

 

To do this first, you need to add the dependency in your app level build.gradle

After adding the dependency you need to create a helper class which will be used whenever you need to get the version name from play store.

 

Now you are ready to get the current version of your app and to get that you need to create an object of your VersionChecker class.

As you can see in the above code variable mLatestVersionName is initialized by versionChecker.execute().get() which returns a string value which is the version name of your app from google play store.

Now you can compare this version name with your current version of the app in the device and perform the required task. Look at the code segment given below for a little help.

 

That all.

Thank you very much. This is Vedesh Kumar signing off.

. . .

Comments (6)

Add Your Comment

  • Arpana K.C.
    It throws error like this:
    Could not read resource entities-xhtml.properties. Make sure you copy resources for org.a.c.i
    • Vedesh Kumar
      Are you using proguard for shrinking?

      You can try :
      1) Disabling the proguard.
      Or
      2) add -keep class org.jsoup.** in you proguard file.

  • Shailesh Vishwase
    It gives nullPointerExeption on ownText(); please suggest me change.
  • vuanhlevis
    if version name like 2.3.5 ?
    so this line:
    Double.parseDouble(BuildConfig.VERSION_NAME) < Double.parseDouble(mLatestVersionName)
    get error ??
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close