List of usage examples for android.hardware SensorManager SENSOR_DELAY_FASTEST
int SENSOR_DELAY_FASTEST
To view the source code for android.hardware SensorManager SENSOR_DELAY_FASTEST.
Click Source Link
From source file:com.kircherelectronics.accelerationfilter.activity.AccelerationPlotActivity.java
/** * Set the sensor delay based on user preferences. 0 = slow, 1 = medium, 2 = * fast.//from w w w. j av a 2s .c om * * @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(); }
From source file:com.prod.intelligent7.engineautostart.ConnectDaemonService.java
private void registerAccelerometerListener() { final SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); }
From source file:com.example.sensingapp.SensingApp.java
private void setDefaultStatus() { m_blnOrientEnabled = false;/* w w w .j ava 2 s . com*/ m_blnGyroEnabled = false; m_blnAcclEnabled = false; m_blnLinearAcclEnabled = false; m_blnGravityEnabled = false; m_blnMagnetEnabled = false; m_blnLightEnabled = false; m_blnBarometerEnabled = false; m_blnWifiEnabled = false; m_blnGPSEnabled = false; m_blnMicEnabled = false; m_blnCellularEnabled = false; m_nOrientMode = SensorManager.SENSOR_DELAY_FASTEST; m_nGyroMode = SensorManager.SENSOR_DELAY_FASTEST; m_nAcclMode = SensorManager.SENSOR_DELAY_FASTEST; m_nLinearAcclMode = SensorManager.SENSOR_DELAY_FASTEST; m_nGravityMode = SensorManager.SENSOR_DELAY_FASTEST; m_nMagnetMode = SensorManager.SENSOR_DELAY_FASTEST; m_nLightMode = SensorManager.SENSOR_DELAY_FASTEST; m_nBarometerMode = SensorManager.SENSOR_DELAY_FASTEST; m_chkOrient.setChecked(false); m_chkGyro.setChecked(false); m_chkAccl.setChecked(false); m_chkLinearAccl.setChecked(false); m_chkGravity.setChecked(false); m_chkMagnet.setChecked(false); m_chkLight.setChecked(false); m_chkBarometer.setChecked(false); m_chkWifi.setChecked(false); m_chkGPS.setChecked(false); enableSensorSetting(true); m_rdSensorOrient.setChecked(true); m_rdSensorModeNormal.setChecked(true); m_blnRecordStatus = false; }
From source file:com.davidmascharka.lips.TrackerActivity.java
@Override public void onResume() { super.onResume(); File root = Environment.getExternalStorageDirectory(); File dir = new File(root.getAbsolutePath() + "/indoor_localization"); dir.mkdirs();// ww w.j av a 2 s .c o m file = new File(dir, "livetest_" + building + ".txt"); valuesFile = new File(dir, "livetest_" + building + "_values.txt"); try { outputStream = new FileOutputStream(file, true); valuesOutputStream = new FileOutputStream(valuesFile, true); writer = new PrintWriter(outputStream); valuesWriter = new PrintWriter(valuesOutputStream); } catch (Exception e) { e.printStackTrace(); } // Set building textview to the building the user has selected //TextView buildingText = (TextView) findViewById(R.id.text_building); //buildingText.setText("Building: " + building); // Set room size textview to the room size the user has selected //TextView roomSizeText = (TextView) findViewById(R.id.text_room_size); //roomSizeText.setText("Room size: " + roomWidth + " x " + roomLength); // Set grid options GridView grid = (GridView) findViewById(R.id.tracker_gridView); //grid.setGridSize(roomWidth, roomLength); grid.setGridSize(102, 64); grid.setCatchInput(false); //grid.setDisplayMap(displayMap); // Register to get sensor updates from all the available sensors sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL); for (Sensor sensor : sensorList) { sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_FASTEST); } // Enable wifi if it is disabled if (!wifiManager.isWifiEnabled()) { Toast.makeText(this, "WiFi not enabled. Enabling...", Toast.LENGTH_SHORT).show(); wifiManager.setWifiEnabled(true); } // Request location updates from gps and the network //@author Mahesh Gaya added permission if-statment if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { Log.i(TAG, "Permissions have NOT been granted. Requesting permissions."); requestMyPermissions(); } else { Log.i(TAG, "Permissions have already been granted. Getting location from GPS and Network"); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); } registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); wifiManager.startScan(); Toast.makeText(this, "Initiated scan", Toast.LENGTH_SHORT).show(); xText = (TextView) findViewById(R.id.tracker_text_xcoord); yText = (TextView) findViewById(R.id.tracker_text_ycoord); }