2

Can I query the Android Market for the latest version of my application in code? I would like to show an update notification for the user when a new version is available.

Related questions:

Community
  • 1
  • 1
apa64
  • 1,578
  • 1
  • 17
  • 26

4 Answers4

4

I bumped into the same problem here. So I thought... why not use AppBrain.

I wrote a small function that gets your latest app version from the AppBrain website.

public String getLatestVersionNumber()
{
    String versionNumber = "0.0.0";

    try
    {
        Document doc = Jsoup.connect("http://www.appbrain.com/app/wallpaper-switch/com.mlevit.wallpaperswitch").get();
        Elements changeLog = doc.select("div.clDesc");

        for (Element div : changeLog)
        {
            String divText = div.text();

            if (divText.contains("Version"))
            {
                return divText.split(" ")[1];
            }

        }
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    return versionNumber;
}

I use the jsoup Java HTML Parser to parse the HTML and from there on it's pretty simple.

Once you've retrieved it, since it's a String the best way I can think of to compare two versions together is to remove the full stops (.) that way your version number would go from say 1.1.2 to 112 then it's just a simple matter of comparing two Integers.

mlevit
  • 2,676
  • 10
  • 42
  • 50
2

I know of no way to make that query, sorry.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

I found this one which might be useful for some people

https://code.google.com/p/android-query/wiki/Service

Mohammad Haque
  • 565
  • 1
  • 7
  • 16
0

I found a work around that may just work. Name you app like this:

My App - V.1.12

Now you can quay your app page on the market. The title will be: My App - V.1.12 - Android Apps on Google Play

Assuming that you change the app name version on each release, this will work.

Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216