List of usage examples for android.hardware SensorManager SENSOR_DELAY_NORMAL
int SENSOR_DELAY_NORMAL
To view the source code for android.hardware SensorManager SENSOR_DELAY_NORMAL.
Click Source Link
From source file:de.tubs.ibr.dtn.dtalkie.TalkieActivity.java
@Override public void onResume() { super.onResume(); SensorManager sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE); List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_PROXIMITY); if (sensors.size() > 0) { Sensor sensor = sensors.get(0);/* ww w .j a v a 2 s. c o m*/ sm.registerListener(mSensorListener, sensor, SensorManager.SENSOR_DELAY_NORMAL); } // set output to speaker setAudioOutput(); }
From source file:edu.cmu.android.restaurant.MapFragment.java
@Override public void onResume() { super.onResume(); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); mLocalActivityManager.dispatchResume(); }
From source file:com.nextgis.mobile.forms.CompassFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // reference to vibrator service vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); // vibrate or not? SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); vibrationOn = prefs.getBoolean("compass_vibration", true); if (mCurrentLocation == null) { LocationManager locationManager = (LocationManager) getActivity() .getSystemService(Context.LOCATION_SERVICE); mCurrentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (mCurrentLocation == null) { mCurrentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); }/* ww w . jav a2 s . c om*/ } mDeclination = 0; if (mCurrentLocation != null) { mDeclination = getDeclination(mCurrentLocation, System.currentTimeMillis()); } sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); sensorManager.registerListener(sensorListener, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL); getActivity().registerReceiver(compassBroadcastReceiver, new IntentFilter(ACTION_COMPASS_UPDATES)); Log.d(TAG, "CompassActivity: onCreate"); }
From source file:root.gast.playground.sensor.altitude.DetermineAltitudeActivity.java
@Override protected void onResume() { super.onResume(); List<String> enabledProviders = locationManager.getProviders(true); if (enabledProviders.isEmpty() || !enabledProviders.contains(LocationManager.GPS_PROVIDER)) { Toast.makeText(this, R.string.gpsNotEnabledMessage, Toast.LENGTH_LONG).show(); } else {/*from ww w. jav a2 s. c o m*/ // Register every location provider returned from LocationManager for (String provider : enabledProviders) { // Register for updates every minute locationManager.requestLocationUpdates(provider, 60000, // minimum time of 60000 ms (1 minute) 0, // Minimum distance of 0 this, null); } } Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE); // Only make registration call if device has a pressure sensor if (sensor != null) { sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL); } }
From source file:ch.bfh.sensordataprocessor.sensor.SensorDisplayFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.sensor_view, null); sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); name = (TextView) layout.findViewById(R.id.name); type = (TextView) layout.findViewById(R.id.type); maxRange = (TextView) layout.findViewById(R.id.maxRange); minDelay = (TextView) layout.findViewById(R.id.minDelay); power = (TextView) layout.findViewById(R.id.power); resolution = (TextView) layout.findViewById(R.id.resolution); vendor = (TextView) layout.findViewById(R.id.vendor); version = (TextView) layout.findViewById(R.id.version); accuracy = (TextView) layout.findViewById(R.id.accuracy); timestampLabel = (TextView) layout.findViewById(R.id.timestampLabel); timestamp = (TextView) layout.findViewById(R.id.timestamp); timestampUnits = (TextView) layout.findViewById(R.id.timestampUnits); dataLabel = (TextView) layout.findViewById(R.id.dataLabel); dataUnits = (TextView) layout.findViewById(R.id.dataUnits); xAxis = (TextView) layout.findViewById(R.id.xAxis); xAxisLabel = (TextView) layout.findViewById(R.id.xAxisLabel); yAxis = (TextView) layout.findViewById(R.id.yAxis); yAxisLabel = (TextView) layout.findViewById(R.id.yAxisLabel); zAxis = (TextView) layout.findViewById(R.id.zAxis); zAxisLabel = (TextView) layout.findViewById(R.id.zAxisLabel); singleValue = (TextView) layout.findViewById(R.id.singleValue); cosLabel = (TextView) layout.findViewById(R.id.cosLabel); cos = (TextView) layout.findViewById(R.id.cos); layout.findViewById(R.id.delayFastest).setOnClickListener(new OnClickListener() { @Override/*from w w w .j av a 2 s . c o m*/ public void onClick(View v) { sensorManager.unregisterListener(SensorDisplayFragment.this); sensorManager.registerListener(SensorDisplayFragment.this, sensor, SensorManager.SENSOR_DELAY_FASTEST); } }); layout.findViewById(R.id.delayGame).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sensorManager.unregisterListener(SensorDisplayFragment.this); sensorManager.registerListener(SensorDisplayFragment.this, sensor, SensorManager.SENSOR_DELAY_GAME); } }); layout.findViewById(R.id.delayNormal).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sensorManager.unregisterListener(SensorDisplayFragment.this); sensorManager.registerListener(SensorDisplayFragment.this, sensor, SensorManager.SENSOR_DELAY_NORMAL); } }); layout.findViewById(R.id.delayUi).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sensorManager.unregisterListener(SensorDisplayFragment.this); sensorManager.registerListener(SensorDisplayFragment.this, sensor, SensorManager.SENSOR_DELAY_UI); } }); return layout; }
From source file:com.abajeli.wearable.gesturecadabra.MainActivity.java
@Override protected void onResume() { super.onResume(); if (mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL)) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Successfully registered for the sensor updates"); }// w ww .jav a2s. co m } }
From source file:com.stillnojetpacks.huffr.activities.MainActivity.java
@Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { Log.i(TAG, "SOUNDPOOL LOAD COMPLETE for sampleId:" + sampleId); loaded.put(sampleId, Boolean.TRUE); if (allSoundsLoaded()) { Log.i(TAG, "ALL SOUNDS LOADED! registering sensorManager"); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); Sensor accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if (accelerometer == null) { Log.i(TAG, "accelerometer is null"); } else {//from w w w.j a v a 2 s .c om sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); } sprayButton.setEnabled(true); capOff(); } }
From source file:pubsub.io.android.example.Pubsub_exampleActivity.java
@Override protected void onResume() { // mPubsub.reconnect(); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); super.onResume(); }
From source file:com.jasompeter.openalpr.CameraActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_camera); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surface_view); mTorchButton = (ImageButton) findViewById(R.id.torch_button); mCapturingText = (TextView) findViewById(R.id.capturing_text); mTouchToCaptureText = (TextView) findViewById(R.id.touch_to_capture); mSurfaceHolder = surfaceView.getHolder(); mSurfaceHolder.addCallback(this); mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // we should not open camera on UI thread mCameraOpenTask = new AsyncTask<Void, Void, Void>() { @Override//from w ww.ja v a 2s. c om protected Void doInBackground(Void[] params) { if (!mCameraIsOpen) { releaseCameraAndPreview(); try { int cameraCount = Camera.getNumberOfCameras(); Log.d(TAG, "We have " + cameraCount + " cameras."); for (int i = 0; i < cameraCount; i++) { Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { mCameraId = i; break; } } mCamera = Camera.open(mCameraId); mCameraIsOpen = true; } catch (Exception e) { mCameraIsOpen = false; Log.d(TAG, "Failed to open camera. Camera is probably in use."); } } return null; } @Override protected void onPostExecute(Void o) { onCameraOpened(mCamera != null); } }; // orientation manager handles orientation changes // because our activity is set to force landscape mode // and we may want rotate action buttons or do something with view mOrientationManager = new OrientationManager(this, SensorManager.SENSOR_DELAY_NORMAL, this); invalidateTorchButton(); mTorchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleTorch(); } }); initializeAlpr(); surfaceView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mEnableRecognition = true; mCapturingText.setVisibility(View.VISIBLE); mTouchToCaptureText.setVisibility(View.GONE); return true; // if you want to handle the touch event case MotionEvent.ACTION_UP: mEnableRecognition = false; mCapturingText.setVisibility(View.GONE); mTouchToCaptureText.setVisibility(View.VISIBLE); return true; // if you want to handle the touch event } return false; } }); }
From source file:com.javadog.cgeowear.cgeoWear.java
/** * Initializes the screen, whether the Activity was freshly-launched or onNewIntent was run. * * @param i The launch intent./*from w ww .jav a 2s . c om*/ */ private void initScreen(Intent i) { String cacheName = i.getStringExtra(MessageDataSet.KEY_CACHE_NAME); String geocode = i.getStringExtra(MessageDataSet.KEY_GEOCODE); distance = i.getFloatExtra(MessageDataSet.KEY_DISTANCE, 0f); direction = i.getFloatExtra(MessageDataSet.KEY_DIRECTION, 0f); geocacheLocation = i.getParcelableExtra(MessageDataSet.KEY_CACHE_LOCATION); //Start listening for compass updates, if the user wants useWatchCompass = i.getBooleanExtra(MessageDataSet.KEY_WATCH_COMPASS, false); if (accelerometer != null && magnetometer != null) { sensorManager.unregisterListener(this, accelerometer); sensorManager.unregisterListener(this, magnetometer); } Log.d(DEBUG_TAG, useWatchCompass ? "Using watch compass." : "Using phone compass."); if (useWatchCompass) { sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); magnetometer = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); sensorManager.registerListener(this, magnetometer, SensorManager.SENSOR_DELAY_NORMAL); } tv_cacheName.setText(cacheName); tv_geocode.setText(geocode); setDistanceFormatted(distance); rotateCompass(direction); }