2010-10-19 32 views
1
locationManager = (LocationManager)context.getSystemService(context.LOCATION_SERVICE); 
Location location = locationManager.getLastKnownLocation(locationManager.NETWORK_PROVIDER); 
Geocoder geocoder = new Geocoder(context); 
List <Address> myLocation = null; 
try { 
myLocation = geocoder.getFromLocation(location.getLatitude(),location.getLongitude(), 1); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

日志低于:GLS与状态20失败-Android获取用户位置

LocationMasfClient: reverseGeocode(): GLS failed with status 20 

我找不到原因。

回答

0

Help! Geocoding fails: forwardGeocode(): GLS failed with status 20如果u使用API​​ V8

通常GLS工作在第二次尝试在我的应用程序...

try { 
       //Place geocoder here 
} catch (IOException e) { 
       //Try again 
       Thread.sleep(1500); 
       Log.e(this.toString(), "Slept for a while (1500 ms). Let's try reverse geocoding again..."); 
       //Place geocoder here again 
       Log.d(this.toString(), "Success! It's always good to take a nap..."); 
}