I’m using a sensor for my Android Application. I register the sensor with a line of code:
mySensorManager.registerListener(this, orientationSensor, SensorManager.SENSOR_DELAY_NORMAL);
I have introduced a line of code to unregister the listener so it wont be running all time:
mySensorManager.unregisterListener(this);
So far it works, but i need to register it again when the application resumes. I need to know if my sensorManager has a registered listener so I can registered again or skit it. Does something like this can be done?:
if (mySensorManager.getRegisteredListenerList == null){ registerListener() } else { .. }
As far as I know, there is no native way to check if you have already registered listener. I would not worry too much about this check since this check is already done by Android, so if you have already registered listener, Android is not gonna add the same listener twice:
So you can call registerListener as many times as you want it will only be added once:)
The same is applicable for unregister logic