List of usage examples for android.hardware SensorManager SENSOR_DELAY_GAME
int SENSOR_DELAY_GAME
To view the source code for android.hardware SensorManager SENSOR_DELAY_GAME.
Click Source Link
From source file:com.thalmic.android.sample.helloworld.HelloWorldActivity.java
protected void onResume() { super.onResume(); // Register a listener for the sensor. sensorManager.registerListener(this, vector, SensorManager.SENSOR_DELAY_NORMAL); sensorManager.registerListener(this, acc, SensorManager.SENSOR_DELAY_NORMAL); sensorManager.registerListener(this, mag, SensorManager.SENSOR_DELAY_GAME); }
From source file:com.google.android.apps.santatracker.games.gumball.TiltGameFragment.java
@Override public void onResume() { super.onResume(); // Resume the game play if the game was not paused if (!wasPaused) { mRotation = getActivity().getWindowManager().getDefaultDisplay().getRotation(); 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); }/* w ww. j a v a2 s. c om*/ mCountDownTimer = new GameCountdown(mFramesPerSecond, mTimeLeftInMillis); mCountDownTimer.start(); mGameView.setGameCountDown(mCountDownTimer); } // Start the game loop if it is not initialised yet if (mGameThread == null) { mGameThread = new Runnable() { public void run() { synchronized (mWorld) { if (!wasPaused) { if (mCurrentLevelNum == 0) { mCurrentLevelNum++; loadLevel(mCurrentLevelNum); } mWorld.update(); mGameView.invalidate(); } } getActivity().getWindow().getDecorView().postDelayed(mGameThread, 10); } }; } getActivity().getWindow().getDecorView().postDelayed(mGameThread, 1000); loadBackgroundMusic(); updateSignInButtonVisibility(); }
From source file:io.github.msc42.masterthemaze.GameActivity.java
@Override protected void onResume() { super.onResume(); if (mGameThread != null) { mGameThread.restart();//from w ww.j a v a2 s .c om } if (mMotion) { if (mSpeed > 0) { mAddCurrentDirectionToQueueThread = new AddCurrentDirectionToQueueThread(mMotionQueue, mCurrentMoveDirection, mSpeed); mAddCurrentDirectionToQueueThread.start(); } SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); Sensor accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mAccelerometerEventListener = new AccelerometerEventListener(mRotation, mSensitivity, mCurrentMoveDirection, mMotionQueue); sensorManager.registerListener(mAccelerometerEventListener, accelerometer, SensorManager.SENSOR_DELAY_GAME, mSensorHandler); } if (mMotion) { mMotionDescriptionTextView.setText(R.string.connecting); } else { mTouchDescriptionTextView.setText(R.string.connecting); mUpButton.setVisibility(View.INVISIBLE); mRightButton.setVisibility(View.INVISIBLE); mDownButton.setVisibility(View.INVISIBLE); mLeftButton.setVisibility(View.INVISIBLE); } }
From source file:org.puder.trs80.EmulatorActivity.java
private void startAccelerometer() { lockOrientation();//w w w . j a va2s. c om if (sensorManager == null) { sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); sensorAccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); } sensorManager.registerListener(this, sensorAccelerometer, SensorManager.SENSOR_DELAY_GAME); }
From source file:org.mozilla.gecko.GeckoAppShell.java
public static void enableDeviceMotion(boolean enable) { LayerView v = GeckoApp.mAppContext.getLayerController().getView(); SensorManager sm = (SensorManager) v.getContext().getSystemService(Context.SENSOR_SERVICE); if (gAccelerometerSensor == null || gOrientationSensor == null) { gAccelerometerSensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); gOrientationSensor = sm.getDefaultSensor(Sensor.TYPE_ORIENTATION); }/*from www . j a va 2 s. c o m*/ if (enable) { if (gAccelerometerSensor != null) sm.registerListener(GeckoApp.mAppContext, gAccelerometerSensor, SensorManager.SENSOR_DELAY_GAME); if (gOrientationSensor != null) sm.registerListener(GeckoApp.mAppContext, gOrientationSensor, SensorManager.SENSOR_DELAY_GAME); } else { if (gAccelerometerSensor != null) sm.unregisterListener(GeckoApp.mAppContext, gAccelerometerSensor); if (gOrientationSensor != null) sm.unregisterListener(GeckoApp.mAppContext, gOrientationSensor); } }
From source file:com.zainsoft.ramzantimetable.QiblaActivity.java
private void registerListeners() { SharedPreferences perfs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SensorManager mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); Sensor gsensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); Sensor msensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); mSensorManager.registerListener(qiblaManager, gsensor, SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(qiblaManager, msensor, SensorManager.SENSOR_DELAY_GAME); schedule();/*from w w w . j a va 2 s . c om*/ isRegistered = true; }
From source file:org.mozilla.gecko.GeckoAppShell.java
public static void enableSensor(int aSensortype) { SensorManager sm = (SensorManager) GeckoApp.mAppContext.getSystemService(Context.SENSOR_SERVICE); switch (aSensortype) { case SENSOR_PROXIMITY: if (gProximitySensor == null) gProximitySensor = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY); sm.registerListener(GeckoApp.mAppContext, gProximitySensor, SensorManager.SENSOR_DELAY_GAME); break;/*from ww w . j av a 2 s.c o m*/ } }
From source file:org.godotengine.godot.Godot.java
@Override protected void onResume() { super.onResume(); if (!godot_initialized) { if (null != mDownloaderClientStub) { mDownloaderClientStub.connect(this); }//from w w w . j av a2 s. co m return; } mView.onResume(); mView.queueEvent(new Runnable() { @Override public void run() { GodotLib.focusin(); } }); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(this, mGyroscope, SensorManager.SENSOR_DELAY_GAME); if (use_immersive && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // check if the application runs on an android 4.4+ Window window = getWindow(); window.getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | // hide nav bar View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } for (int i = 0; i < singleton_count; i++) { singletons[i].onMainResume(); } }
From source file:com.cellbots.logger.LoggerActivity.java
private void initSensorLogFiles() { sensorLogFileWriters = new HashMap<String, BufferedWriter>(); String directoryName = application.getDataLoggerPath(); File directory = new File(directoryName); if (!directory.exists() && !directory.mkdirs()) { try {/*from w w w . ja v a2s . c o m*/ throw new IOException("Path to file could not be created. " + directory.getAbsolutePath()); } catch (IOException e) { Log.e(TAG, "Directory could not be created. " + e.toString()); } } for (int i = 0; i < sensors.size(); i++) { Sensor s = sensors.get(i); String sensorFilename = directoryName + s.getName().replaceAll(" ", "_") + "_" + application.getFilePathUniqueIdentifier() + ".txt"; File file = new File(sensorFilename); try { BufferedWriter writer = new BufferedWriter(new FileWriter(file)); sensorLogFileWriters.put(s.getName(), writer); } catch (IOException e) { e.printStackTrace(); } mSensorManager.registerListener(mSensorEventListener, s, SensorManager.SENSOR_DELAY_GAME); } // The battery is a special case since it is not a real sensor mBatteryTempWriter = createBufferedWriter("/BatteryTemp_", directoryName); mBatteryLevelWriter = createBufferedWriter("/BatteryLevel_", directoryName); mBatteryVoltageWriter = createBufferedWriter("/BatteryVoltage_", directoryName); // GPS is another special case since it is not a real sensor mGpsLocationWriter = createBufferedWriter("/GpsLocation_", directoryName); mGpsStatusWriter = createBufferedWriter("/GpsStatus_", directoryName); mGpsNmeaWriter = createBufferedWriter("/GpsNmea_", directoryName); // Wifi is another special case mWifiWriter = createBufferedWriter("/Wifi_", directoryName); }
From source file:com.kircherelectronics.accelerationfilter.activity.AccelerationPlotActivity.java
/** * Set the sensor delay based on user preferences. 0 = slow, 1 = medium, 2 = * fast.// w w w . j a v a2s . c o m * * @param position * The desired sensor delay. */ private void setSensorDelay(int position) { switch (position) { case 0: sensorManager.unregisterListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); // Register for sensor updates. sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); break; case 1: sensorManager.unregisterListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); // Register for sensor updates. sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME); break; case 2: sensorManager.unregisterListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); // Register for sensor updates. sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); break; } lpf.reset(); meanFilter.reset(); }