1

I have been using the geocoding from android app. It was working ok. Suddenly past 10 hours I started getting null response from google webservices server. The following is the sample url.

https://maps.googleapis.com/maps/api/geocode/json?latlng=12.971729,77.6516641

and I download this using the following method which gets called from a asynctask

  private JSONObject GeocodeUrl(String strUrl) throws IOException {

    InputStream iStream = null;
    HttpURLConnection urlConnection = null;
    JSONObject jsonObject = new JSONObject();

    try{
        URL url = new URL(strUrl);

        // Creating an http connection to communicate with url
        urlConnection = (HttpURLConnection) url.openConnection();

        // Connecting to url
        urlConnection.connect();

        // Reading data from url
        iStream = urlConnection.getInputStream();

        BufferedReader br = new BufferedReader(new InputStreamReader(iStream));

        StringBuffer sb  = new StringBuffer();

        String line = "";
        while( ( line = br.readLine())  != null){
            sb.append(line);
        }


        try {
            jsonObject = new JSONObject(sb.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }

        br.close();

    }catch(Exception e){
        Log.d("Geocode error", e.toString());
    }finally{
        iStream.close();
        urlConnection.disconnect();
    }

    return jsonObject;
}

The return jsonobject is null.

I don't' use any apikey in the url. Because the geocoding api key is for server side and we need to enter the ip address in the google api console

This app is not yet released in play store and still under testing. This issue happens in all devices.

Please let me know what could be the problem.

user1123931
  • 479
  • 1
  • 8
  • 24

0 Answers0