Amap's onLocationChanged often returns latitude and longitude (0). Why?

when I enter the interface, I start to call the location function to get the current longitude and latitude from onLocationChanged. When
automatically relocates 10 seconds later, most of the latitude and longitude returned to me by onLocationChanged are zero and zero. Why is this happening? Is it because my position has not moved, so return to 0 for me? Or some other reason, ask the boss to explain, thank you!

private AMapLocationListener locationListener = new AMapLocationListener() {
        @Override
        public void onLocationChanged(AMapLocation aMapLocation) {
            if (null != aMapLocation) {
                location = aMapLocation;
                getLocation(aMapLocation);//location0
                Log.i("tang","="+location.getLatitude()+"//"+location.getLongitude());
                System.out.println("===========" + getLocationStr(aMapLocation));
            } else {
                System.err.println("===========");
            }

        }
    };

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

May.14,2021

found the reason, because after Gaud 2.0, AppService services will be added to Manifest. Add it and you can quickly get the location.

Menu