react-native-sensor-manager icon indicating copy to clipboard operation
react-native-sensor-manager copied to clipboard

Gyroscope event not triggered

Open herdani opened this issue 9 years ago • 3 comments

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
});

herdani avatar Dec 09 '16 13:12 herdani

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 ...

herdani avatar Dec 09 '16 15:12 herdani

What's the solution?

I have the same problem. In my situation Orientation event is never triggered either, which could be related.

kennethjiang avatar Sep 08 '17 13:09 kennethjiang

Never mind. It turns out my Android device doesn't have a gyro or magnetometer. :(

kennethjiang avatar Sep 08 '17 13:09 kennethjiang