Search code examples
androidgpsandroid-8.0-oreogoogle-pixel

GnssStatus.Callback no working in android 8


I have used

public class MyGPSStatusV24 extends GnssStatus.Callback {

        @Override
        public void onStarted() {
            super.onStarted();
            myLogApp.log("[onGpsStatusChanged] GPS_EVENT_STARTED...");

        }

        @Override
        public void onStopped() {
            super.onStopped();
            myLogApp.log("[onGpsStatusChanged] GPS_EVENT_STOPPED...");

        }

        @Override
        public void onSatelliteStatusChanged(GnssStatus status) {
            super.onSatelliteStatusChanged(status);
            myLogApp.log("[onGpsStatusChanged] onSatelliteStatusChanged...");
        }

        @Override
        public void onFirstFix(int ttffMillis) {
            super.onFirstFix(ttffMillis);
            myLogApp.log("[onGpsStatusChanged] GPS_EVENT_FIRST_FIX...");

        }
    }

for checking the GPS status in android 8.

And in the main there is:

mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            mlocListener = new MyLocationListener();

            if(Build.VERSION.SDK_INT < Build.VERSION_CODES.N ){
                ...
            }else{
                mlocManager.registerGnssStatusCallback(new MyGPSStatusV24());
            }
            mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener);

But the methods in MyGPSStatusV24 were never triggered.

Even I disable GPS, the onStopped wasn´t be triggered.

I have tried this code in an Android 7 device and worked but when I use google pixel no working. I don´t know if this is a bug in google pixel o in android 8.


Solution

  • OK, I have tested and the Bug is from the device, it´s not a codec bug.