List of usage examples for android.hardware SensorManager SENSOR_DELAY_UI
int SENSOR_DELAY_UI
To view the source code for android.hardware SensorManager SENSOR_DELAY_UI.
Click Source Link
From source file:at.amartinz.hardware.sensors.BaseSensor.java
public int getSensorDelay() { return SensorManager.SENSOR_DELAY_UI; }
From source file:step.StepService.java
public void registerDetector() { if (mSensorManager != null && mStepDetector != null) { mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(mStepDetector, mSensor, SensorManager.SENSOR_DELAY_FASTEST); // Step Detector mSensorManager.registerListener(mStepDetector2, mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER), SensorManager.SENSOR_DELAY_UI); }/*from w ww. j a v a2s . c om*/ }
From source file:com.microsoft.mimickeralarm.mimics.MimicWithCameraFragment.java
@Override public void onStart() { super.onStart(); if (mSensorManager != null && mLightSensorListener != null) { mSensorManager.registerListener(mLightSensorListener, mLightSensor, SensorManager.SENSOR_DELAY_UI); }//from w w w. j a va 2s .co m mStateManager.start(); }
From source file:org.streetpacman.DMBoard.java
/** * Registers to receive location updates from the GPS location provider and * sensor updated from the compass./* w w w. j av a 2 s .c o m*/ */ void registerLocationAndSensorListeners() { if (locationManager != null) { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); try { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000 * 60 * 5 /* minTime */, 0 /* minDist */, locationListener); } catch (RuntimeException e) { // If anything at all goes wrong with getting a cell location do // not // abort. Cell location is not essential to this app. Log.w(DMConstants.TAG, "Could not register network location listener."); } } if (sensorManager == null) { return; } Sensor compass = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); if (compass == null) { return; } Log.d(DMConstants.TAG, "DM: Now registering sensor listeners."); sensorManager.registerListener(sensorListener, compass, SensorManager.SENSOR_DELAY_UI); }
From source file:com.sorin.cloudcog.car.obd2.RubyBluetoothChatActivity.java
@Override public synchronized void onResume() { super.onResume(); if (D)/*from w w w. j a v a2 s.co m*/ Log.e(TAG, "+ ON RESUME +"); // Add the following line to register the Session Manager Listener // onResume mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI); // Performing this check in onResume() covers the case in which BT was // not enabled during onStart(), so we were paused to enable it... // onResume() will be called when ACTION_REQUEST_ENABLE activity // returns. if (mChatService != null) { // Only if the state is STATE_NONE, do we know that we haven't // started already if (mChatService.getState() == BluetoothChatService.STATE_NONE) { // Start the Bluetooth chat services mChatService.start(); } } }
From source file:org.y20k.trackbook.TrackerService.java
private void startTracking(Intent intent) { LogHelper.v(LOG_TAG, "Service received command: START"); // create a new track mTrack = new Track(); // get last location if (intent.hasExtra(EXTRA_LAST_LOCATION)) { mCurrentBestLocation = intent.getParcelableExtra(EXTRA_LAST_LOCATION); }/* w w w. j a v a2 s. co m*/ // get last location - fallback if (mCurrentBestLocation == null) { mCurrentBestLocation = LocationHelper.determineLastKnownLocation(mLocationManager); } // add last location as WayPoint to track addWayPointToTrack(); // set timer to retrieve new locations and to prevent endless tracking mTimer = new CountDownTimer(EIGHT_HOURS_IN_MILLISECONDS, FIFTEEN_SECONDS_IN_MILLISECONDS) { @Override public void onTick(long millisUntilFinished) { // update track duration long duration = EIGHT_HOURS_IN_MILLISECONDS - millisUntilFinished; mTrack.setDuration(duration); // try to add WayPoint to Track addWayPointToTrack(); // update notification NotificationHelper.update(mTrack, true); } @Override public void onFinish() { // remove listeners stopFindingLocation(); } }; mTimer.start(); // initialize step counter mStepCountOffset = 0; Sensor stepCounter = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER); if (stepCounter != null) { mSensorManager.registerListener(this, stepCounter, SensorManager.SENSOR_DELAY_UI); } else { LogHelper.v(LOG_TAG, "Pedometer Sensor not available"); mTrack.setStepCount(-1); } // put up notification NotificationHelper.show(this, mTrack); // create gps and network location listeners startFindingLocation(); // register content observer for changes in System Settings this.getContentResolver().registerContentObserver(android.provider.Settings.Secure.CONTENT_URI, true, mSettingsContentObserver); }
From source file:com.sorin.cloudcog.car.obd2.SilverBluetoothChatActivity.java
@Override public synchronized void onResume() { super.onResume(); if (D)/*from ww w . jav a 2s. co m*/ Log.e(TAG, "+ ON RESUME +"); // Performing this check in onResume() covers the case in which BT was // not enabled during onStart(), so we were paused to enable it... // onResume() will be called when ACTION_REQUEST_ENABLE activity // returns. if (mChatService != null) { // Only if the state is STATE_NONE, do we know that we haven't // started already if (mChatService.getState() == BluetoothChatService.STATE_NONE) { // Start the Bluetooth chat services mChatService.start(); // Add the following line to register the Session Manager // Listener // onResume mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI); } } }
From source file:com.example.haber.ui.activity.TabbedActivity.java
@Override protected void onResume() { super.onResume(); lastTime = System.currentTimeMillis(); try {//from w w w. ja v a 2 s . c o m sensorListener = new SensorEventListener() { @Override public void onSensorChanged(SensorEvent event) { try { long currentTime = System.currentTimeMillis(); long intevalTime = currentTime - lastTime; if (intevalTime < 50) return; lastTime = currentTime; float[] values = event.values; float x = values[0]; float y = values[1]; float z = values[2]; float detaX = x - lastX; float detaY = y - lastY; float detaZ = z - lastZ; lastX = x; lastY = y; lastZ = z; if ((Math.sqrt(detaX * detaX + detaY * detaY + detaZ * detaZ) / intevalTime) * 100 < SENSOR_SENSITIVITY) return; if (vibrator == null) return; vibrator.vibrate(300); long currentSwitchPanTime = System.currentTimeMillis(); if (currentSwitchPanTime - lastSwichPanTime < 1000) return; lastSwichPanTime = currentSwitchPanTime; switchPan(); } catch (Exception e) { ExceptionUtil.handlerException(e); } } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } }; if (currentStatus == CONSOLE_CONTROL_STATUS) { if (sensor == null) return; sensorManager.registerListener(sensorListener, sensor, SensorManager.SENSOR_DELAY_UI); } handlerCallStatus(); } catch (Exception e) { ExceptionUtil.handlerException(e); } }
From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.ColorimetryLiquidActivity.java
private void initializeTest() { mSensorManager.unregisterListener(mShakeDetector); mIgnoreShake = false;//from w ww.j a v a 2s . c o m mTestCompleted = false; mHighLevelsFound = false; mWaitingForStillness = true; if (ApiUtil.isCameraInUse(this, null)) { releaseResources(); finish(); } mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI); }
From source file:il.ac.shenkar.todos.view.MainActivity.java
@Override protected void onResume() { super.onResume(); // reopen database taskListModel.getDataBase().open();/*from ww w . j ava2s. c om*/ // register sensors resources mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_UI); adapter.notifyDataSetChanged(); }