Android 未收到完整的google directions api响应

Android 未收到完整的google directions api响应,android,json,google-directions-api,Android,Json,Google Directions Api,我正在使用Android的Google Directions API并得到JSON响应。唯一的问题是响应停止在15422个字符之后准确地接收(即响应在第四步的中间时完全停止)。我尝试改变缓冲区大小,但仍然是一样的。我永远无法得到完整的答复。你知道为什么会这样吗 [编辑] 这是请求指示的代码 Location currentLocation; String urlShowDirections = ""; if(currentLocation != null){ urlShowDirect

我正在使用Android的Google Directions API并得到JSON响应。唯一的问题是响应停止在15422个字符之后准确地接收(即响应在第四步的中间时完全停止)。我尝试改变缓冲区大小,但仍然是一样的。我永远无法得到完整的答复。你知道为什么会这样吗

[编辑] 这是请求指示的代码

Location currentLocation;
String urlShowDirections = ""; 
if(currentLocation != null){
    urlShowDirections = "http://maps.googleapis.com/maps/api/directions/json?"+
                        "origin="+currentLocation.getLatitude()+","+currentLocation.getLongitude()+
                        "&destination="+nearestAtmLL.latitude+","+nearestAtmLL.longitude+
                        "&sensor=false";
}
URL url = new URL(urlShowDirections);
new LocateDirections().execute(url);
这是在后台处理请求的异步任务

class LocateDirections extends AsyncTask<URL, Void, Void>{

    @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;
    }
}
class LocateDirections扩展异步任务{
@凌驾
受保护的Void doInBackground(URL…URL){
HttpURLConnection conn=null;
final StringBuilder json=新StringBuilder();
试一试{
//连接到web服务
conn=(HttpURLConnection)url[0]。openConnection();
Log.i(标记“Connection-”+conn.toString());
InputStreamReader in=新的InputStreamReader(conn.getInputStream());
//将json数据读入字符串生成器
int-read;
char[]buff=新字符[4096];
while((read=in.read(buff))!=-1){
append(buff,0,read);
i(标记“Response char total-”+json.length());
Log.i(标记“字符读取-”+读取);
}
i(标记“方向响应-”+json.toString());
}捕获(IOE异常){
Log.e(标记“IO错误-尝试建立连接时出错”);
e、 printStackTrace();
}捕获(JSONException e){
e(标记“JSON错误-解析JSON响应时出错”);
e、 printStackTrace();
}最后{
如果(conn!=null){
连接断开();
}
}
返回null;
}
}
[编辑2]
我检查了不同来源和目的地的应用程序。这一次,没有收到不同的字符。但是多次尝试使用不同的缓冲区大小表明响应完全停止在同一位置,就像以前一样。

需要查看您如何调用的代码块