Gyroscope event not triggered
The listener 'Gyroscope' is never triggered, I have no errors at all, but nothing never happens. I suppose my code is Ok since all other sensors are working well. Tried on a Samsung and a Sony device. Any idea ?
import React, {DeviceEventEmitter} from 'react-native';
var mSensorManager = require('NativeModules').SensorManager;
mSensorManager.startGyroscope(100);
DeviceEventEmitter.addListener('Gyroscope', function(data) {
// Got never here
});
Hint: While trying to debug (don't know Android nor Java, so quite hard), I found out that, in file
react-native-sensor-manager/android/src/main/java/com/sensormanager/GyroscopeRecord.java
if ((mGyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)) != null) {
always returns null ...
What's the solution?
I have the same problem. In my situation Orientation event is never triggered either, which could be related.
Never mind. It turns out my Android device doesn't have a gyro or magnetometer. :(