Android programmatically update application when a new version is available

前端 未结 9 1859
别那么骄傲
别那么骄傲 2020-12-01 08:45

Within my application, I want to check if there is any updated version of my application is in the app store. If there is any, then have to inform the user through an alert

相关标签:
9条回答
  • 2020-12-01 09:25

    Beware of policy violations, Google will suspend your App if any 3rd party frameworks used for App update, this happened to me recently.

    0 讨论(0)
  • 2020-12-01 09:27

    I have the same issue but it resolved by JSOUP library. Here is the library download link: http://jsoup.org/download

    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);
    
    0 讨论(0)
  • 2020-12-01 09:28

    Well there is another way I figured out and this is how I am doing it.

    HttpPost httppostUserName = new HttpPost("https://androidquery.appspot.com/api/market?app=com.supercell.clashofclans"); //your package name
    HttpClient httpclient = new DefaultHttpClient();
    
    HttpResponse responseUser = httpclient.execute(httppostUserName);
    String responseStringUser = EntityUtils.toString(responseUser.getEntity(), HTTP.UTF_8);
    
    Log.d(Constants.TAG, "Response: " + responseStringUser);
    try {
        JSONObject Json = new JSONObject(responseStringUser);
        newVersion = Json.getString("version");
    } catch (Exception e) {
        e.printStackTrace();
    }
    

    You will get a clearer view if you paste the url in your browser to see the results.

    0 讨论(0)
提交回复
热议问题