我正在构建一个谷歌方向服务的查询,但执行方法中途崩溃了,这是代码
Uri.Builder b = Uri.parse("http://maps.googleapis.com/maps/api/directions/json").buildUpon();
b.appendQueryParameter("origin", "The University of Hong KOng");
b.appendQueryParameter("destination", "Lee Hysan Hall");
b.appendQueryParameter("sensor", "false");
b.appendQueryParameter("language", "en_US");
String finalstr = b.build().toString();
URI googledirectionservice = new URI(finalstr);
HttpGet mRequest = new HttpGet(googledirectionservice);
HttpClient mClient = new DefaultHttpClient();
response = mClient.execute(mRequest);
当我从浏览器访问它时构建的url很好,但是从HttpClient访问它是行不通的。你可以用
进行双重检查http://maps.googleapis.com/maps/api/directions/json?origin=The%20University%20of%20Hong%20KOng&destination=Lee%20Hysan%20Hall&sensor=false&language=en_US
原因是什么?此外,如何使调试信息更具信息性? logcat中的当前文件只显示
threadid=... thread exiting with uncaught exception