Java Code Examples for android.hardware.SensorManager#SENSOR_STATUS_UNRELIABLE

The following examples show how to use android.hardware.SensorManager#SENSOR_STATUS_UNRELIABLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AeyriumSensorPlugin.java    From aeyrium-sensor with MIT License 6 votes vote down vote up
SensorEventListener createSensorEventListener(final EventChannel.EventSink events) {
  return new SensorEventListener() {
    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
      if (mLastAccuracy != accuracy) {
        mLastAccuracy = accuracy;
      }
    }

    @Override
    public void onSensorChanged(SensorEvent event) {
      if (mLastAccuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
        return;
      }

      updateOrientation(event.values, events);
    }
  };
}
 
Example 2
Source File: AppRTCProximitySensor.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
public final void onAccuracyChanged(Sensor sensor, int accuracy) {
  threadChecker.checkIsOnValidThread();
  AppRTCUtils.assertIsTrue(sensor.getType() == Sensor.TYPE_PROXIMITY);
  if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
    LogUtil.e(TAG, "The values returned by this sensor cannot be trusted");
  }
}
 
Example 3
Source File: PBarometer.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
public void start() {
    super.start();

    mListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {
            ReturnObject r = new ReturnObject();
            r.put("bar", event.values[0]);
            mCallback.event(r);
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            switch (accuracy) {
                case SensorManager.SENSOR_STATUS_UNRELIABLE:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                    break;
            }
        }

    };

    isEnabled = mSensormanager.registerListener(mListener, sensor, speed);
}
 
Example 4
Source File: PStep.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
@PhonkMethod(description = "Start the step counter. Not superacurate and only few devices", example = "")
@PhonkMethodParam(params = {"function(value)"})
public void start() {
    super.start();

    mListener = new SensorEventListener() {
        @Override
        public void onSensorChanged(SensorEvent event) {
            mCallback.event(null);
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            switch (accuracy) {
                case SensorManager.SENSOR_STATUS_UNRELIABLE:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                    break;
            }
        }

    };

    isEnabled = mSensormanager.registerListener(mListener, sensor, speed);
}
 
Example 5
Source File: AppRTCProximitySensor.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@Override
public final void onAccuracyChanged(Sensor sensor, int accuracy) {
    threadChecker.checkIsOnValidThread();
    AppRTCUtils.assertIsTrue(sensor.getType() == Sensor.TYPE_PROXIMITY);
    if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
        Log.e(Config.LOGTAG, "The values returned by this sensor cannot be trusted");
    }
}
 
Example 6
Source File: PRotationVector.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
public void start() {
    super.start();

    mListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {
            if (mCallback != null) {
                ReturnObject r = new ReturnObject();
                r.put("x", event.values[0]);
                r.put("y", event.values[1]);
                r.put("z", event.values[2]);
                mCallback.event(r);
            }
        }


        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            switch (accuracy) {
                case SensorManager.SENSOR_STATUS_UNRELIABLE:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                    break;
            }
        }

    };

    isEnabled = mSensormanager.registerListener(mListener, sensor, speed);
}
 
Example 7
Source File: PAccelerometer.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
public void start() {
    super.start();

    mListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {
            if (mCallback != null) {
                ReturnObject r = new ReturnObject();
                r.put("x", event.values[0]);
                r.put("y", event.values[1]);
                r.put("z", event.values[2]);
                float force = (float) Math.sqrt(Math.pow(event.values[0], 2) + Math.pow(event.values[1], 2) + Math.pow(event.values[2], 2));
                r.put("force", force);
                mCallback.event(r);
                MLog.d(TAG, "accelerometer changed");
            }
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            switch (accuracy) {
                case SensorManager.SENSOR_STATUS_UNRELIABLE:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                    break;
            }
        }

    };

    isEnabled = mSensormanager.registerListener(mListener, sensor, speed);
}
 
Example 8
Source File: PLinearAcceleration.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
public void start() {
    super.start();

    mListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {
            if (mCallback != null) {
                ReturnObject r = new ReturnObject();
                r.put("x", event.values[0]);
                r.put("y", event.values[1]);
                r.put("z", event.values[2]);
                float force = (float) Math.sqrt(Math.pow(event.values[0], 2) + Math.pow(event.values[1], 2) + Math.pow(event.values[2], 2));
                r.put("force", force);
                mCallback.event(r);
            }
        }


        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            switch (accuracy) {
                case SensorManager.SENSOR_STATUS_UNRELIABLE:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                    break;
            }
        }

    };

    isEnabled = mSensormanager.registerListener(mListener, sensor, speed);
}
 
Example 9
Source File: POrientation.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
@PhonkMethod(description = "Start the orientation sensor. Returns pitch, roll, yaw", example = "")
@PhonkMethodParam(params = {"function(pitch, roll, yaw)"})
public void start() {
    super.start();

    mListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {
            ReturnObject r = new ReturnObject();
            r.put("azimuth", event.values[0]);
            r.put("pitch", event.values[1]);
            r.put("roll", event.values[2]);

            mCallbackOrientationChange.event(r);
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            switch (accuracy) {
                case SensorManager.SENSOR_STATUS_UNRELIABLE:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                    break;
            }
        }

    };

    isEnabled = mSensormanager.registerListener(mListener, sensor, speed);
}
 
Example 10
Source File: GaugePanel.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType() == Sensor.TYPE_PRESSURE) {
        if (event.accuracy == SensorManager.SENSOR_STATUS_NO_CONTACT || event.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
            setValue(Gauge.TYPE_ELEVATION, Float.NaN);
        } else {
            // https://en.wikipedia.org/wiki/Pressure_altitude (converted to meters)
            float elevation = (float) ((1 - Math.pow(event.values[0] / SensorManager.PRESSURE_STANDARD_ATMOSPHERE, 0.190284)) * 145366.45 / 3.281);
            setValue(Gauge.TYPE_ELEVATION, elevation);
        }
    }
}
 
Example 11
Source File: PMagneticField.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
@PhonkMethod(description = "Start the magneticField sensor", example = "")
@PhonkMethodParam(params = {"function(value)"})
public void start() {
    super.start();

    mListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {
            ReturnObject r = new ReturnObject();
            r.put("x", event.values[0]);
            r.put("y", event.values[1]);
            r.put("z", event.values[2]);
            mCallbackMagneticChange.event(r);
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            switch (accuracy) {
                case SensorManager.SENSOR_STATUS_UNRELIABLE:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                    break;
            }
        }

    };

    isEnabled = mSensormanager.registerListener(mListener, sensor, speed);
}
 
Example 12
Source File: PLightIntensity.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
@PhonkMethod(description = "Start the light sensor. Returns the intensity. The value per device might vary", example = "")
@PhonkMethodParam(params = {"function(intensity)"})
public void start() {
    super.start();

    mListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {
            ReturnObject r = new ReturnObject();
            r.put("intensity", event.values[0]);
            mCallbackLightChange.event(r);
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            switch (accuracy) {
                case SensorManager.SENSOR_STATUS_UNRELIABLE:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                    break;
                case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                    break;
            }
        }

    };

    isEnabled = mSensormanager.registerListener(mListener, sensor, speed);
}
 
Example 13
Source File: GaugePanel.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
    if (sensor.getType() == Sensor.TYPE_PRESSURE) {
        if (accuracy == SensorManager.SENSOR_STATUS_NO_CONTACT || accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE)
            setValue(Gauge.TYPE_ELEVATION, Float.NaN);
    }
}
 
Example 14
Source File: AppRTCProximitySensor.java    From Yahala-Messenger with MIT License 5 votes vote down vote up
@Override
public final void onAccuracyChanged(Sensor sensor, int accuracy) {
    checkIfCalledOnValidThread();
    AppRTCUtils.assertIsTrue(sensor.getType() == Sensor.TYPE_PROXIMITY);
    if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
        Log.e(TAG, "The values returned by this sensor cannot be trusted");
    }
}
 
Example 15
Source File: SensorsActivity.java    From android-motion-detector with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
    if (sensor == null) throw new NullPointerException();

    if (sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD && accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
        Log.e(TAG, "Compass data unreliable");
    }
}
 
Example 16
Source File: AccelListener.java    From jpHolo with MIT License 5 votes vote down vote up
/**
 * Stop listening to acceleration sensor.
 */
private void stop() {
    stopTimeout();
    if (this.status != AccelListener.STOPPED) {
        this.sensorManager.unregisterListener(this);
    }
    this.setStatus(AccelListener.STOPPED);
    this.accuracy = SensorManager.SENSOR_STATUS_UNRELIABLE;
}
 
Example 17
Source File: AppRTCProximitySensor.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@Override
public final void onAccuracyChanged(Sensor sensor, int accuracy) {
    threadChecker.checkIsOnValidThread();
    AppRTCUtils.assertIsTrue(sensor.getType() == Sensor.TYPE_PROXIMITY);
    if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
        Log.e(Config.LOGTAG, "The values returned by this sensor cannot be trusted");
    }
}
 
Example 18
Source File: AccelListener.java    From cordova-android-chromeview with Apache License 2.0 5 votes vote down vote up
/**
 * Stop listening to acceleration sensor.
 */
private void stop() {
    if (this.status != AccelListener.STOPPED) {
        this.sensorManager.unregisterListener(this);
    }
    this.setStatus(AccelListener.STOPPED);
    this.accuracy = SensorManager.SENSOR_STATUS_UNRELIABLE;
}
 
Example 19
Source File: AppRTCProximitySensor.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public final void onAccuracyChanged(Sensor sensor, int accuracy)
{
   checkIfCalledOnValidThread();
   AppRTCUtils.assertIsTrue(sensor.getType() == Sensor.TYPE_PROXIMITY);
   if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
      RCLogger.e(TAG, "The values returned by this sensor cannot be trusted");
   }
}
 
Example 20
Source File: ARActivity.java    From ar-location-based-android with MIT License 4 votes vote down vote up
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
    if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
        Log.w("DeviceOrientation", "Orientation compass unreliable");
    }
}