accelerometer - Unexpected false return value from android.hardware.SensorManager.registerListener in Android 4.3 -
used lg nexus 4, android 4.3
the return value false , don't understand why. documentation says: "true if sensor supported , enabled."
what strange no examples i've seen testing return value sensormanager.registerlistener.
strange if ignore false value returned works expected!
documentation: http://developer.android.com/reference/android/hardware/sensormanager.html
android.hardware.sensormanager, android.hardware.systemsensormanager
my code:
sensormanager sensormgr = (sensormanager)_context.getsystemservice(context.sensor_service); if (sensormgr == null) { log.w(tag, "200410::sensors not supported"); return false; } sensor sensor = sensormgr.getdefaultsensor(sensor.type_proximity); result = sensormgr.registerlistener(this, sensor, sensormanager.sensor_delay_normal); if( result == false) { // should done here // since false return value indicated registration failed. // found it's better doing nothing since registration seams ok } return result;
the strange false return value did not happened before android 4.3
so, ok if result value not used in examples. maybe should satisfied that, but, have 3 questions:
- why return value never tested in examples?
- why return value false in android 4.3?
- why working if return value false?
i understand these questions difficult answer happy if info else have same problem.
i got same behavior both sensor.type_accelerometer , sensor.type_proximity
Comments
Post a Comment