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

发布于 2024-09-28 01:43:42 字数 626 浏览 0 评论 0原文

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

我找不到原因。

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

The log is below:

LocationMasfClient: reverseGeocode(): GLS failed with status 20

I can not find the reason.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日暮斜阳 2024-10-05 01:43:42

请参阅帮助!地理编码失败:forwardGeocode(): 如果您使用 API v8,GLS 失败,状态为 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...");
}

See Help! Geocoding fails: forwardGeocode(): GLS failed with status 20 if u use API v8

Often GLS works on the second try in my app...

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...");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文