【问题标题】:LocationManager Not Providing the Exact Location For First time in samsung devicesLocationManager 首次在三星设备中未提供确切位置
【发布时间】:2021-01-28 22:05:21
【问题描述】:

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

注意:三星 M 系列和 A 系列 - Android 版本 10

出现此问题

【问题讨论】:

    标签: android location android-gps


    【解决方案1】:

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

    以前我是这样用的

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-05
      • 2011-10-28
      • 2012-05-06
      相关资源
      最近更新 更多