开发者

Querying latest application version from the Android Market

开发者 https://www.devze.com 2023-01-15 05:22 出处:网络
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.

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:

  • Process in updating my app in the market
  • Is there a way to automatically upd开发者_StackOverflow中文版ate application on Android?
  • Android Market Application Updates


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.


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


I found this one which might be useful for some people

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消