2010-10-19 49 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..."); 
}