Skip to content

Commit

Permalink
Avoid registering the sensor if it is null (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
rocboronat authored and Sloy committed Dec 7, 2016
1 parent 085cbb2 commit 59fef9a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public void unSubscribe() {

public void registerSensorManager() {
if (sensorManager != null) {
sensorManager.registerListener(this,
sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), DEFAULT_SAMPLING_PERIOD);
Sensor rotationVectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
if (rotationVectorSensor != null) {
sensorManager.registerListener(this, rotationVectorSensor, DEFAULT_SAMPLING_PERIOD);
}
}
}

Expand Down Expand Up @@ -192,4 +194,4 @@ public void setTiltSensitivity(float tiltSensitivity) {

mTiltSensitivity = tiltSensitivity;
}
}
}

0 comments on commit 59fef9a

Please sign in to comment.