How to get app market version information from google play store?

后端 未结 15 1608
孤独总比滥情好
孤独总比滥情好 2020-11-29 00:33

How can I get the application version information from google play store for prompting the user for force/recommended an update of the application when play store applicatio

15条回答
  •  误落风尘
    2020-11-29 00:50

    You can call the following WebService: http://carreto.pt/tools/android-store-version/?package=[YOUR_APP_PACKAGE_NAME]

    Example Using Volley:

    String packageName = "com.google.android.apps.plus";
    String url = "http://carreto.pt/tools/android-store-version/?package=";
    JsonObjectRequest jsObjRequest = new JsonObjectRequest
        (Request.Method.GET, url+packageName, null, new Response.Listener() {
                        @Override
                        public void onResponse(JSONObject response) {
                            /*
                                    here you have access to:
    
                                    package_name, - the app package name
                                    status - success (true) of the request or not (false)
                                    author - the app author
                                    app_name - the app name on the store
                                    locale - the locale defined by default for the app
                                    publish_date - the date when the update was published
                                    version - the version on the store
                                    last_version_description - the update text description
                                 */
                            try{
                                if(response != null && response.has("status") && response.getBoolean("status") && response.has("version")){
                                    Toast.makeText(getApplicationContext(), response.getString("version").toString(), Toast.LENGTH_LONG).show();
                                }
                                else{
                                    //TODO handling error
                                }
                            }
                            catch (Exception e){
                                //TODO handling error
                            }
    
                        }
                    }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            //TODO handling error
                        }
            });
    

提交回复
热议问题