Android开发中,反向地理编码时,报连接被拒绝的错误 1C

如题,在将经纬度转成地理位置时,在使用Google API时,连接总是错误,但是在电脑浏览器上却可以。
1. StringBuilder url = new StringBuilder();

                url.append("http://maps.google.com/maps/api/geocode/json?latlng=");
                url.append(latitude).append(",");
                url.append(longitude);
                url.append("&sensor=false");
                Log.d("TWO", "00000000000000");
                HttpClient httpClient = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet(url.toString());
                // 在请求消息头中指定语言,保证服务器会返回中文数据
                httpGet.addHeader("Accept-Language", "zh-CN");
                Log.d("TWO", "1111111111111111111");
                try
                {
                    HttpResponse httpResponse = httpClient.execute(httpGet);
                    if (httpResponse.getStatusLine().getStatusCode() == 200)
                    {
                        HttpEntity entity = httpResponse.getEntity();
                        String response = EntityUtils.toString(entity,
                                "utf-8");
                        Log.d("TWO", "2222222222222222");
                        Message msg = Message.obtain();
                        msg.what = 0;
                        msg.obj = response;
                        handler.sendMessage(msg);

                    }else {
                        Log.d("TWO", "3333333333333333333333");
                    }
                } catch (Exception e)
                {
                    // TODO: handle exception
                    Log.d("TWO", e.toString());
                }

日志打印000000000000000和1111111111111111,最后打印出错误,大概是connection to XXXX refusal。。求哪位大神赐教

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问