GLS失败,状态为20 -Android获取用户位置

时间:2010-10-19 21:18:37

标签: android gps location

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();
        }

日志如下:

LocationMasfClient: reverseGeocode(): GLS failed with status 20

我找不到原因。

1 个答案:

答案 0 :(得分:0)

如果您使用API​​ v8

,请参阅Help! Geocoding fails: forwardGeocode(): GLS failed with status 20

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...");
}