Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Get Android app version from Play Store link andorid

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 499
    Comment on it

    This blog is about get current version of Android app on Play Store android using Jsoup. There is no official API to get version number but we can get it by reading HTML.  

    Here we start.

    1. Create Project.

    2. Open Manifest file and add Internet permission.

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

    3. Open Gradle file and add below line to compile Jsoup library.

     compile 'org.jsoup:jsoup:1.9.2'

    4. Open Activity class.

    5. Create new Thread.

    6. Create Document object.

     Document doc = null;

    7. Initialize with Jsoup.connect.

     doc = Jsoup.connect("YUOR_APPLICATION_URL").get();

    8. Get Elements which use css class '.meta-info .content' :-

    Elements cssElements = doc.select(".meta-info .content");

    9. Get Single element from position 4th.

    Element ele = cssElements.get(3);

    10. You will get <DIV> of app version. Now you can get <div> value to get Version number.

     Elements text = ele.select("div");
                        String versionNumber = text.text();

    11. Full Stack Code.

    new Thread(new Runnable() {
                @Override
                public void run() {
                    Document doc = null;
                    try {
                        doc = Jsoup.connect("TYPE_APP_URL_HERE").get();
                        Elements cssElements = doc.select(".meta-info .content");
                        Element ele = cssElements.get(3);
    
                        Elements text = ele.select("div");
                        String versionNumber = text.text();
    
                        Log.i("App version:- ",versionNumber);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }).start();

     

    Happy coding :D

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: