Geocoder类在android中无法正常工作

Asw*_*wan 1 android

我的应用程序我正在使用Geocoder类来检索位置纬度和longtude

我的代码是:

addressInput = street+","+city+","+pin+","+country; 
List<Address> foundAdresses = gc.getFromLocationName(addressInput, 5);
Run Code Online (Sandbox Code Playgroud)

第一次抛出这样的异常

java.io.IOException:无法解析来自服务器的响应

ERROR/ProtoRequestListener(566):com.google.common.async.WatchdogException

请妥协解决它,如果你有任何代码检索位置纬度和经度发送给我

Nar*_*mha 5

这应该可以解决您的问题.

List<Address> addresses = 
          new Geocoder(this,Locale.getDefault()).getFromLocation(lat, lon, 1);
Run Code Online (Sandbox Code Playgroud)