سؤال

I'd like to get actual proximity from proximity sensor, but the default behavior is to register a listener and wait for the value change. I don't want to wait for change, but I want to get actual value. Is that possible?

    mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
    mSensorManager.registerListener(this, mProximity, 0);
هل كانت مفيدة؟

المحلول

There is no way to get the direct value of a Sensor in Java (Don't know for native code)

You must rely on the SensorChanged implementation to get a value from a Sensor.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top