Example usage for android.hardware SensorManager SENSOR_DELAY_FASTEST

List of usage examples for android.hardware SensorManager SENSOR_DELAY_FASTEST

Introduction

In this page you can find the example usage for android.hardware SensorManager SENSOR_DELAY_FASTEST.

Prototype

int SENSOR_DELAY_FASTEST

To view the source code for android.hardware SensorManager SENSOR_DELAY_FASTEST.

Click Source Link

Document

get sensor data as fast as possible

Usage

From source file:MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    mSensorManager.registerListener(mSensorListener, mMagnetometer, SensorManager.SENSOR_DELAY_FASTEST);
    mSensorManager.registerListener(mSensorListener, mAccelerometer, SensorManager.SENSOR_DELAY_FASTEST);
}

From source file:pl.mrwojtek.sensrec.app.SamplingPeriodDialog.java

public static int getSamplingPosition(long delay) {
    if (delay == SensorManager.SENSOR_DELAY_NORMAL) {
        return POSITION_NORMAL;
    } else if (delay == SensorManager.SENSOR_DELAY_UI) {
        return POSITION_UI;
    } else if (delay == SensorManager.SENSOR_DELAY_GAME) {
        return POSITION_GAME;
    } else if (delay == SensorManager.SENSOR_DELAY_FASTEST) {
        return POSITION_FASTEST;
    } else {// ww  w. j ava2 s.c om
        return POSITION_CUSTOM;
    }
}

From source file:com.androtux.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    CommunicationHandler.getInstance().connect();
    _sManager.registerListener(this, _sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_FASTEST);
}

From source file:com.artur.softwareproject.BaroService.java

public void onCreate() {
    super.onCreate();

    baroManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    baroSensor = baroManager.getDefaultSensor(Sensor.TYPE_PRESSURE);

    baroManager.registerListener(this, baroSensor, SensorManager.SENSOR_DELAY_FASTEST);

    filter = new SimpleKalmanFilter(0.013, 0.0000005);
}

From source file:com.nikhilnayak.games.octoshootar.beta.SensorDelayDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Sensor Delay");

    final ArrayList<String> sensorDelayString = new ArrayList<String>();
    sensorDelayString.add("Delay Fastest");
    sensorDelayString.add("Delay Game");
    sensorDelayString.add("Delay Ui");
    sensorDelayString.add("Delay Normal");

    final ArrayList<Integer> sensorDelayInteger = new ArrayList<Integer>();
    sensorDelayInteger.add(SensorManager.SENSOR_DELAY_FASTEST);
    sensorDelayInteger.add(SensorManager.SENSOR_DELAY_GAME);
    sensorDelayInteger.add(SensorManager.SENSOR_DELAY_UI);
    sensorDelayInteger.add(SensorManager.SENSOR_DELAY_NORMAL);

    final SharedPreferences sharedPreferences = getActivity()
            .getSharedPreferences(BetaUtils.KEY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
    final SharedPreferences.Editor sharedPreferencesEditor = sharedPreferences.edit();

    int currentSensorDelayIndex = sensorDelayInteger
            .indexOf(sharedPreferences.getInt(BetaUtils.KEY_SENSOR_DELAY, SensorManager.SENSOR_DELAY_GAME));

    builder.setSingleChoiceItems(sensorDelayString.toArray(new String[] {}), currentSensorDelayIndex,
            new DialogInterface.OnClickListener() {
                @Override/*from w w  w  .  j a v  a 2s . c  o m*/
                public void onClick(DialogInterface dialog, int which) {
                    sharedPreferencesEditor.putInt(BetaUtils.KEY_SENSOR_DELAY, sensorDelayInteger.get(which));
                }
            });

    builder.setPositiveButton(R.string.craft_dialog_fragment_ok_response,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    sharedPreferencesEditor.commit();
                }
            });

    return builder.create();
}

From source file:eu.intermodalics.tango_ros_streamer.ImuNode.java

public void onStart(ConnectedNode connectedNode) {
    mConnectedNode = connectedNode;//from   ww  w.j  av a 2 s  . c  o  m
    mLog = connectedNode.getLog();
    mImuPublisher = connectedNode.newPublisher("android/imu", Imu._TYPE);
    mImuMessage = mConnectedNode.getTopicMessageFactory().newFromType(Imu._TYPE);

    mSensorManager.registerListener(this, mRotationSensor, SensorManager.SENSOR_DELAY_FASTEST);
    mSensorManager.registerListener(this, mGyroscopeSensor, SensorManager.SENSOR_DELAY_FASTEST);
    mSensorManager.registerListener(this, mAccelerometerSensor, SensorManager.SENSOR_DELAY_FASTEST);
}

From source file:ch.fhnw.comgr.GLES3Activity.java

@Override
protected void onResume() {
    Log.i(TAG, "GLES3Activity.onResume");
    super.onResume();
    myView.onResume();//from  w  w w . j  a va 2s .  c o  m

    if (mSensorManager != null)
        mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
                SensorManager.SENSOR_DELAY_FASTEST);
}

From source file:com.kircherelectronics.androidlinearacceleration.sensor.AccelerationSensor.java

/**
 * Register for Sensor.TYPE_ACCELEROMETER measurements.
 * /*from  www  .  java  2 s  .  co  m*/
 * @param observer
 *            The observer to be registered.
 */
public void registerAccelerationObserver(AccelerationSensorObserver observer) {
    // If there are currently no observers, but one has just requested to be
    // registered, register to listen for sensor events from the device.
    if (observersAcceleration.size() == 0) {
        sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
                SensorManager.SENSOR_DELAY_FASTEST);
    }

    // Only register the observer if it is not already registered.
    int i = observersAcceleration.indexOf(observer);
    if (i == -1) {
        observersAcceleration.add(observer);
    }

}

From source file:com.kircherelectronics.fusedlinearacceleration.sensor.GyroscopeSensor.java

/**
 * Register for Sensor.TYPE_GYROSCOPE measurements.
 * /*from w  w w.  j a v a  2s. co  m*/
 * @param observer
 *            The observer to be registered.
 */
public void registerGyroscopeObserver(GyroscopeSensorObserver observer) {
    if (observersGyroscope.size() == 0) {
        sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
                SensorManager.SENSOR_DELAY_FASTEST);
    }

    // Only register the observer if it is not already registered.
    int i = observersGyroscope.indexOf(observer);
    if (i == -1) {
        observersGyroscope.add(observer);
    }
}

From source file:com.configurer.easyscreenlock.service.ForegroundSensorService.java

protected void registerListener() {
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

    if (isSensorAvailable()) {
        sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);

        /**//from w w w.  ja v  a2  s.  c om
         * Showing available sensor on Device
         * */
        showAvailableSensors();

        listener = new ProximitySensorEventListener(this);

        boolean isRegistered = mSensorManager.registerListener(listener, sensor,
                SensorManager.SENSOR_DELAY_FASTEST);

        Log.i(TAG, "Registering listener : " + isRegistered);
    } else {
        Log.w(TAG, "Proximity Sensor not available, sorry :( ");
    }
}