在 Google Play 上查詢應用程序當前版本的更快方法? (Faster Way to Query Application's Current Version on Google Play?)


問題描述

在 Google Play 上查詢應用程序當前版本的更快方法? (Faster Way to Query Application's Current Version on Google Play?)

I would like to be able to compare, on application start, the running version against the same application's version currently on Google Play.

I found a nice way to this, described here:

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

But it's way too slow and significantly hampers user experience on application start.

Is there a faster way to query application's current version on Google Play?

Perhaps some hidden LVL or in-app billing API?


參考解法

方法 1:

  

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. 

(by Bill The ApeCommonsWare)

參考文件

  1. Faster Way to Query Application's Current Version on Google Play? (CC BY-SA 3.0/4.0)

#android-lvl #Android #google-play #in-app-billing






相關問題

這種 Google LVL 政策實施是否合理安全? (Would this Google LVL policy implementation be reasonably secure?)

在 SDK 管理器中找不到 Google 市場許可包 (Cant find Google Market Licensing package in SDK Manager)

在 Google Play 上查詢應用程序當前版本的更快方法? (Faster Way to Query Application's Current Version on Google Play?)

Android 應用許可檢查 (Android app licensing check)

Ứng dụng Giấy phép Android hiển thị Không được cấp phép? (Android License App showing Not-licensed?)

導入 com.google.android.vending 無法在導入的 android 項目中解析 (The import com.google.android.vending cannot be resolved in an imported android project)

Android“Not_Market_Managed”錯誤 (Android “Not_Market_Managed” error)

是否可以向服務添加許可證檢查(使用許可證驗證庫)? (Is it possible to add a license check (using License Verification Library) to a Service?)

應用程序許可和 android 唯一 ID (Application Licensing and android unique id)

Android 許可 - 每個 Android 開發者帳戶只有一個公鑰? (Android Licensing - Only one public key per Android Developer account?)

測試 Android LVL,許可證檢查總是失敗,沒有網絡 (Testing Android LVL, license check always fails with no network)

什麼時候從服務器返回 LICENSED_OLD_KEY? (When is LICENSED_OLD_KEY returned from server?)







留言討論