android – Location not detected if GPS/Location is ON, but I have no Wifi or mobile data Nougat 7.0 Huawei-ThrowExceptions

Exception or error:

I am trying to create an app that detects the location based on GPS only, as the user might be in an area with no internet connection what so ever.

I used the maps callback function:

mMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
        @Override
        public void onMyLocationChange(Location location) {
            Log.e("Maps", "Location Changed");
         }
}

I also implemented LocationListener:

locationManager.requestLocationUpdates(locationProvider, 1000, 0, this);  
@Override
    public void onLocationChanged(Location location) {
        Log.e("LocationManager","Location changed");
        if(!location.isFromMockProvider()){
         Log.e("LocationManager", "Location Changed");
        }
    }

Neither of the above methods get called if I only have GPS/Location information ON on my 2 Huawei devices having android Nougat API 24. However, they work normally on my Samsung device having android M API 23.


I tested the same devices using the google maps app in order to exclude the possibility of a bug in my app. On the huawei API 24 devices I never see the blue dot determining my location. On the Samsung API 23 I see the blue dot regardless if the map is loaded or not, which is expected because of having no internet to load the map.

N.B: I tried setting the location settings to GPS only and “Use GPS, WIFI, mobile network”. Both, give the same result.

Is this caused by the Huawei devices? Or is it related to the android API 24? Is there a way to fix this?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *