LocationManager首次未在三星设备中提供确切位置

问题描述

我正在获取用户的当前位置,当我第一次单击它时显示不同的位置(即距当前位置超过10公里) 而且,如果我再次单击该按钮,它将显示确切的当前位置

注意:问题发生在三星M系列和A系列-Android版本10

解决方法

在我的情况下,我解决了这样的问题,

在我这样使用之前

location_gps_image.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View vw) {
            if (location != null) {
                
                double latitude = location.getLatitude();
                double longitude = location.getLongitude();
             
                LatLng cur_Latlng = new LatLng(latitude,longitude);
                googleMap.moveCamera(CameraUpdateFactory.newLatLng(cur_Latlng));
                googleMap.animateCamera(CameraUpdateFactory.zoomTo(17));

         
          }
    });

我不是这样更新的,它对我有用

location_gps_image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View vw) {
                if (location != null) {
                    double latitude = location.getLatitude();
                    double longitude = location.getLongitude();
                    
                    LatLng cur_Latlng = new LatLng(latitude,longitude);
                    CameraUpdate currentLocation = CameraUpdateFactory.newLatLngZoom(cur_Latlng,17);
                    googleMap.animateCamera(currentLocation);

            }
        });

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...