Note that there are some explanatory texts on larger screens.

plurals
  1. POComplete google directions api response is not received
    primarykey
    data
    text
    <p>I am using Google Directions API for Android and getting a JSON response. Only problem is the response stops receiving exactly after 15422 characters (i.e. response stops exactly while in the middle of the 4th step). I tried varying the buffer size but it is still the same. I could never receive the full response. Any idea as to why this is?</p> <p>[EDIT] Here's the code for requesting directions.</p> <pre><code>Location currentLocation; String urlShowDirections = ""; if(currentLocation != null){ urlShowDirections = "http://maps.googleapis.com/maps/api/directions/json?"+ "origin="+currentLocation.getLatitude()+","+currentLocation.getLongitude()+ "&amp;destination="+nearestAtmLL.latitude+","+nearestAtmLL.longitude+ "&amp;sensor=false"; } URL url = new URL(urlShowDirections); new LocateDirections().execute(url); </code></pre> <p>This is the AsyncTask that handles the request in background.</p> <pre><code>class LocateDirections extends AsyncTask&lt;URL, Void, Void&gt;{ @Override protected Void doInBackground(URL... url) { HttpURLConnection conn = null; final StringBuilder json = new StringBuilder(); try{ //connect to web service conn = (HttpURLConnection) url[0].openConnection(); Log.i(TAG, "Connection - "+conn.toString()); InputStreamReader in = new InputStreamReader(conn.getInputStream()); //read json data into string builder int read; char[] buff = new char[4096]; while ((read = in.read(buff)) != -1) { json.append(buff, 0, read); Log.i(TAG, "Response char total - "+json.length()); Log.i(TAG, "Chars read - "+read); } Log.i(TAG, "Directions Response - "+json.toString()); } catch (IOException e) { Log.e(TAG, "IO Error - Error in trying to establish a connnection"); e.printStackTrace(); } catch (JSONException e) { Log.e(TAG, "JSON Error - Error in parsing json response"); e.printStackTrace(); } finally { if (conn != null) { conn.disconnect(); } } return null; } } </code></pre> <p>[EDIT 2] I checked the application with different origin and destination. This time, no of characters received is different. But multiple tries with different buffer sizes shows that the response stops exactly at the same position, like before.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload