There are some devices that doesn't have built-in sensor to use compass
what i am trying to do here is to navigate or show message to the user if the phone doesn't support this feature
i am trying this:
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION)
if (sensor !== null) {
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
}else{
val intent = Intent(this, SetProfileActivity::class.java)
startActivity(intent)
}
but get this error every time:
sensorManager.getDefault…(Sensor.TYPE_ORIENTATION) must not be null
what am i doing wrong?