Example usage for android.hardware SensorManager SENSOR_DELAY_GAME

List of usage examples for android.hardware SensorManager SENSOR_DELAY_GAME

Introduction

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

Prototype

int SENSOR_DELAY_GAME

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

Click Source Link

Document

rate suitable for games

Usage

From source file:br.com.rescue_bots_android.bluetooth.MainActivity.java

@Override
protected void onResume() {

    SharedPreferences settings = this.getSharedPreferences(ConfigActivity.PREFS_NAME, 0);
    robottype = settings.getString(ConfigActivity.PARAM_BOTTYPE, "");
    if (robottype != null && robottype.equalsIgnoreCase("FLAREGUN")) {
        routeController.selectAll(coordinates);
    } else if (robottype != null && robottype.equalsIgnoreCase("SAVIOUR")) {
        selectRouteFromServices(coordinates);
    }//from  w w w .  j  a va 2s.  c o  m
    accuraccy = settings.getInt(ConfigActivity.PARAM_ACCURACCY, 10);

    Log.d(TAG, "Resumed");
    super.onResume();

    // for the system's orientation sensor registered listeners
    mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
            SensorManager.SENSOR_DELAY_GAME);

    if (mBTSocket == null || !mIsBluetoothConnected) {
        new ConnectBT().execute();
    }

}

From source file:com.google.android.apps.santatracker.games.gumball.TiltGameFragment.java

/**
 * Continue the paused game.//from   w w w. j  av a  2  s  .c o  m
 * Restart the countdown timer and hide the pause game screen.
 */
private void unPauseGame() {
    mViewPauseButton.setVisibility(View.VISIBLE);
    mViewPlayButton.setVisibility(View.GONE);
    mViewMatchPauseOverlay.setVisibility(View.GONE);
    mViewCancelBar.setVisibility(View.GONE);
    mCountDownTimer = new GameCountdown(mFramesPerSecond, mTimeLeftInMillis);
    mCountDownTimer.start();
    mGameView.setGameCountDown(mCountDownTimer);
    wasPaused = false;
    SensorManager sensorManager = (SensorManager) getActivity().getSystemService(Activity.SENSOR_SERVICE);
    Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    if (sensor != null) {
        sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME);
    }
    if (Utils.hasKitKat()) {
        ImmersiveModeHelper.setImmersiveSticky(getActivity().getWindow());
    }
}