I am trying to detect whether the GPS in the phone is being used or not. So far, GpsStatus listener has been working fine for my Android devices. In the case of SDK 24, I have been using GnssStatus.callback. I have checked that callback is successfully registered. However, still I am not receiving any notification when Google Map uses GPS. My callback function is the following
public final GnssStatus.Callback gnssStatusListener = new GnssStatus.Callback() {
@Override
public void onStarted() {
Log.d(APP_NAME,"GPS started");
}
@Override
public void onStopped() {
Log.d(APP_NAME,"GPS stopped");
}
@Override
public void onSatelliteStatusChanged(GnssStatus status) {
Log.d(APP_NAME,"GPS started"+status.toString());
}
};
The callback function is registered inside a permission check block.
if(ContextCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_FINE_LOCATION ) == PackageManager.PERMISSION_GRANTED){
if(Build.VERSION.SDK_INT==24){
manager.registerGnssStatusCallback(gnssStatusListener);
}
Log.d(APP_NAME, "ACCESS_FINE_LOCATION premission granted");
}
I am not quite sure what is happening. Thanks a lot for your help.