Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to verify app version on play store programmatically?

Tags:

android

I have an application on play store and i would like to do the following:

When the user starts the application it should verify if the application's version that is on play store is the same that is installed and if NOT i will show a dialog to alert this situation with an option to redirect to play store to update it.

I know that the play store's application do this automatically but if the user change this configuration.. this is a problem!

A tried to find a solution over the internet but without success, any help?? :D

like image 893
cristianchiess Avatar asked Dec 21 '22 06:12

cristianchiess


2 Answers

There is no official way to do this, However you can take a look at

https://code.google.com/p/android-market-api/.

You can search the market using your package name and then extract the version number from it, Follow the example here.

A better/simpler solution would be to host a xml file (or even a .txt file) online and store the current version inside it. then check it on your App's startup.

like image 51
Nimooli Avatar answered Jan 07 '23 04:01

Nimooli


Please use the JSoup library fr getting version from playstore.

String newVersion = Jsoup
                        .connect(
                                "https://play.google.com/store/apps/details?id="
                                        + "Package Name" + "&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();

                Log.e("new Version", newVersion);
like image 32
Ahmad Arslan Avatar answered Jan 07 '23 03:01

Ahmad Arslan