3

アプリケーションの起動時に、実行中のバージョンを現在 Google Play にある同じアプリケーションのバージョンと比較できるようにしたいと考えています。

ここで説明されている、これに対する良い方法を見つけました:

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;
}

しかし、これは遅すぎて、アプリケーションの起動時のユーザー エクスペリエンスを大幅に妨げます。

Google Play でアプリケーションの現在のバージョンを照会するより高速な方法はありますか?

おそらく、隠されたLVLまたはアプリ内課金APIでしょうか?

4

1 に答える 1

5

Are you sure there isn't any API that provides the Google Play version much faster?

Well, by definition, network access is slow. Even if Google Play had a documented, supported, and licensed API (they don't as of the time of this writing), it would only be incrementally faster than what you are doing.

Can you post your suggestion on how to do that via AsyncTask?

Step #1: Create a file.

Step #2: In that file, type in your version number, optionally along with other data (e.g., description of update) in some format (e.g., JSON).

Step #3: Upload that file to some well-known stable URL.

Step #4: Create an AsyncTask, putting the HTTP request for your file in doInBackground() of an AsyncTask, with updating your UI (preferably via something non-modal) in the onPostExecute() of that same AsyncTask.

Here is a sample project demonstrating an AsyncTask that performs an HTTP operation (pulling a weather forecast from the US National Weather Service) and parsing the result, updating the UI (populating a WebView) when done.

于 2012-08-12T21:58:33.003 に答える