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:com.nextgis.mobile.forms.CameraFragment.java
public void onCapturePhoto() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri fileUri = getOutputMediaFileUri(); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name mAngles.clear();//from w w w . ja va 2s . c om sensorManager.registerListener(sensorListener, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL); // start the image capture Intent startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); }
From source file:com.nextgis.maplibui.fragment.CompassFragment.java
@Override public void onResume() { mSensorManager.registerListener(sensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL); setInterface();//from w ww. j a va2 s. c o m super.onResume(); }
From source file:org.wso2.carbon.iot.android.sense.ActivitySelectSensor.java
@Override public void onDialogPositiveClick(SelectSensorDialog dialog) { Log.d("Selected sensors", dialog.getSet().toString()); selectedSensorSet = dialog.getSet(); update();// w w w.j a v a2 s . com unregisterSensors(); SenseScheduleReceiver senseScheduleReceiver = new SenseScheduleReceiver(); senseScheduleReceiver.clearAbortBroadcast(); senseScheduleReceiver.onReceive(this, null); /** * Get the selected sensors * Register them * */ SensorViewAdaptor adaptor1 = new SensorViewAdaptor(getApplicationContext(), TempStore.realTimeSensors); adaptor1.notifyDataSetChanged(); sensorReader = new RealTimeSensorReader(this, adaptor1); getSensors(); for (Sensor s : sensors) { sensorManager.registerListener(sensorReader, s, SensorManager.SENSOR_DELAY_NORMAL); } realTimeSensorChangeReceiver.updateOnChange(adaptor1); listView.setAdapter(adaptor1); }
From source file:com.mhennessy.mapfly.MainActivity.java
@Override protected void onResume() { super.onResume(); mSensorManager.registerListener(this, mOrientationSensor, SensorManager.SENSOR_DELAY_NORMAL); mSensorManager.registerListener(this, mAccelerationSensor, SensorManager.SENSOR_DELAY_GAME); }
From source file:de.uni_weimar.benike.misex3.MainActivity.java
@Override public void onResume() { super.onResume(); mSensorManager.registerListener(this, mAccelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL); }
From source file:com.sitewhere.android.example.ExampleFragment.java
/** * Only schedule SiteWhere reporting thread once we have a connection to the server. */// ww w . j ava 2 s. c o m public void startDeviceMonitoring() { Log.d(TAG, "Starting device monitoring."); getActivity().runOnUiThread(new Runnable() { @Override public void run() { // Start location updates. boolean locationStarted = false; locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { Log.d(TAG, "No permissions for location. Requesting permissions from user."); requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION }, LOCATION_REQUEST_CODE); return; } if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ExampleFragment.this); locationStarted = true; Log.d(TAG, "Started monitoring locations via GPS provider."); } else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, ExampleFragment.this); locationStarted = true; Log.d(TAG, "Started monitoring locations via network provider."); } else { locationStarted = false; Log.d(TAG, "No location provider available. Will not monitor location."); } // Start accelerometer updates. boolean accelerometerStarted = false; sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); if (sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null) { rotationVector = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); sensorManager.registerListener(ExampleFragment.this, rotationVector, SensorManager.SENSOR_DELAY_NORMAL); accelerometerStarted = true; Log.d(TAG, "Started monitoring accelerometer."); } else { Toast.makeText(getActivity().getApplicationContext(), "Unable to start accelerometer updates. No accelerometer provided", Toast.LENGTH_LONG); accelerometerStarted = false; Log.d(TAG, "Unable to monitor accelerometer."); } // Send alerts to SiteWhere. SiteWhereMessageClient messageClient = SiteWhereMessageClient.getInstance(); try { if (locationStarted) messageClient.sendDeviceAlert(messageClient.getUniqueDeviceId(), "location.started", "Started to read location data.", null); } catch (SiteWhereMessagingException ex) { Log.e(TAG, "Unable to send location.started alert to SiteWhere."); } try { if (accelerometerStarted) messageClient.sendDeviceAlert(messageClient.getUniqueDeviceId(), "accelerometer.started", "Started to read accelerometer data.", null); } catch (SiteWhereMessagingException e) { Log.e(TAG, "Unable to send accelerometer.started alert to SiteWhere."); } if (scheduler != null) { scheduler.shutdownNow(); } scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.scheduleAtFixedRate(new SiteWhereDataReporter(), SEND_INTERVAL_IN_SECONDS, SEND_INTERVAL_IN_SECONDS, TimeUnit.SECONDS); Log.d(TAG, "Set up scheduler for monitoring."); } }); }
From source file:com.achep.acdisplay.services.activemode.sensors.ProximitySensor.java
@Override public void onStart(@NonNull SensorManager sensorManager) { if (DEBUG)/*from w w w. j av a 2s. c o m*/ Log.d(TAG, "Starting proximity sensor..."); mHistory.clear(); mHistory.add(new Event(false, getTimeNow())); Config.getInstance().registerListener(this); updateWave2WakeProgram(); // Ignore pocket program's start delay, // so app can act just after it has started. mFirstChange = true; mPocketProgram.dataArray[0].timeMin = 0; Sensor proximitySensor = sensorManager.getDefaultSensor(getType()); sensorManager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_NORMAL); mMaximumRange = proximitySensor.getMaximumRange(); sAttached = true; }
From source file:org.wso2.carbon.iot.android.sense.realtimeviewer.ActivitySelectSensor.java
@Override public void onDialogPositiveClick(SelectSensorDialog dialog) { Log.d("Selected sensors", dialog.getSet().toString()); selectedSensorSet = dialog.getSet(); update();//w ww. j a v a 2 s .c o m unregisterSensors(); SenseScheduleReceiver senseScheduleReceiver = new SenseScheduleReceiver(); senseScheduleReceiver.clearAbortBroadcast(); senseScheduleReceiver.onReceive(this, null); /** * Get the selected sensors * Register them * */ SensorViewAdaptor adaptor1 = new SensorViewAdaptor(getApplicationContext(), TempStore.sensorArrayList); adaptor1.notifyDataSetChanged(); sensorReader = new RealTimeSensorReader(this, adaptor1); getSensors(); for (Sensor s : sensors) { sensorManager.registerListener(sensorReader, s, SensorManager.SENSOR_DELAY_NORMAL); } realTimeSensorChangeReceiver.updateOnChange(adaptor1); listView.setAdapter(adaptor1); }
From source file:com.google.android.apps.santatracker.dasherdancer.DasherDancerActivity.java
@Override public void onResume() { super.onResume(); SensorManager manager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); Sensor accel = manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); manager.registerListener(this, accel, SensorManager.SENSOR_DELAY_NORMAL); mDetector.start(manager);/*from w w w . j a v a 2 s . co m*/ if (mInitialized) { //Start the animation for the first character. mPager.postDelayed(new Runnable() { @Override public void run() { loadAnimation(true, sCharacters[mPager.getCurrentItem()].getDuration(Character.ANIM_IDLE), sCharacters[mPager.getCurrentItem()].getFrameIndices(Character.ANIM_IDLE), sCharacters[mPager.getCurrentItem()].getFrames(Character.ANIM_IDLE)); } }, 300); } else { if (mLoadAllBitmapsTask != null) { mLoadAllBitmapsTask.cancel(true); } mLoadAllBitmapsTask = new LoadAllBitmapsTask(); mLoadAllBitmapsTask.execute(sCharacters[mPager.getCurrentItem()]); } }
From source file:org.wheelmap.android.fragment.POIsOsmdroidFragment.java
@Override public void onResume() { super.onResume(); if (mOrientationAvailable) { mSensorManager.registerListener(mMyLocationProvider, mSensor, SensorManager.SENSOR_DELAY_NORMAL); }/*from ww w . ja v a 2s. c o m*/ executeState(retrieveExecuteBundle()); }