Code example for Sensor

Methods: getMaximumRange

        public ProximitySensorEventListener(SensorManager sensorManager, Sensor proximitySensor,
                Listener listener) {
            mSensorManager = sensorManager;
            mProximitySensor = proximitySensor;
            mMaxValue = proximitySensor.getMaximumRange();
            mListener = listener;
            // Initialize at far state. 
            mLastState = State.FAR;
            mWaitingForFarState = false;
        public void onSensorChanged(SensorEvent event) {
            // Make sure we have a valid value. 
            if (event.values == null) return;
            if (event.values.length == 0) return;
            float value = event.values[0];
            // Convert the sensor into a NEAR/FAR state. 
            State state = getStateFromValue(value);
Connect your IDE to all the code out there  Get Codota for Java