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:Main.java
public static boolean startSensor(int sensorType, SensorEventListener listener) { Sensor sensor = getSensor(sensorType); return sensor != null && sensorManager.registerListener(listener, sensor, SensorManager.SENSOR_DELAY_NORMAL); }
From source file:MainActivity.java
@Override protected void onResume() { super.onResume(); mSensorManager.registerListener(mSensorListener, mSensor, SensorManager.SENSOR_DELAY_NORMAL); }
From source file:pl.mrwojtek.sensrec.app.SamplingPeriodDialog.java
public static int getSamplingPosition(long delay) { if (delay == SensorManager.SENSOR_DELAY_NORMAL) { return POSITION_NORMAL; } else if (delay == SensorManager.SENSOR_DELAY_UI) { return POSITION_UI; } else if (delay == SensorManager.SENSOR_DELAY_GAME) { return POSITION_GAME; } else if (delay == SensorManager.SENSOR_DELAY_FASTEST) { return POSITION_FASTEST; } else {/* w w w .jav a 2s.c o m*/ return POSITION_CUSTOM; } }
From source file:com.wx.iseeweather.GetPressurePlugin.GetPressure.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; mSensorManager = (SensorManager) this.cordova.getActivity().getSystemService(Context.SENSOR_SERVICE); mPressure = mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE); if (mPressure != null) { currentNumberOfReadings = 0;//www .j a va 2 s . co m mSensorManager.registerListener(this, mPressure, SensorManager.SENSOR_DELAY_NORMAL); PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); result.setKeepCallback(true); callbackContext.sendPluginResult(result); return true; } else { callbackContext.error("No pressure sensor found."); return false; } }
From source file:org.durka.hallmonitor.ViewCoverProximityService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(LOG_TAG + ".oSC", "View cover Proximity service started"); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY), SensorManager.SENSOR_DELAY_NORMAL); return START_STICKY; }
From source file:com.phonegap.TempListener.java
public void start() { List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_TEMPERATURE); if (list.size() > 0) { this.mSensor = list.get(0); this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL); }/* w w w . j a va 2s.c o m*/ }
From source file:com.nikhilnayak.games.octoshootar.beta.SensorDelayDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Sensor Delay"); final ArrayList<String> sensorDelayString = new ArrayList<String>(); sensorDelayString.add("Delay Fastest"); sensorDelayString.add("Delay Game"); sensorDelayString.add("Delay Ui"); sensorDelayString.add("Delay Normal"); final ArrayList<Integer> sensorDelayInteger = new ArrayList<Integer>(); sensorDelayInteger.add(SensorManager.SENSOR_DELAY_FASTEST); sensorDelayInteger.add(SensorManager.SENSOR_DELAY_GAME); sensorDelayInteger.add(SensorManager.SENSOR_DELAY_UI); sensorDelayInteger.add(SensorManager.SENSOR_DELAY_NORMAL); final SharedPreferences sharedPreferences = getActivity() .getSharedPreferences(BetaUtils.KEY_SHARED_PREFERENCES, Context.MODE_PRIVATE); final SharedPreferences.Editor sharedPreferencesEditor = sharedPreferences.edit(); int currentSensorDelayIndex = sensorDelayInteger .indexOf(sharedPreferences.getInt(BetaUtils.KEY_SENSOR_DELAY, SensorManager.SENSOR_DELAY_GAME)); builder.setSingleChoiceItems(sensorDelayString.toArray(new String[] {}), currentSensorDelayIndex, new DialogInterface.OnClickListener() { @Override/*from ww w .ja v a2 s .com*/ public void onClick(DialogInterface dialog, int which) { sharedPreferencesEditor.putInt(BetaUtils.KEY_SENSOR_DELAY, sensorDelayInteger.get(which)); } }); builder.setPositiveButton(R.string.craft_dialog_fragment_ok_response, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { sharedPreferencesEditor.commit(); } }); return builder.create(); }
From source file:com.commonsware.android.sensor.monitor.MainActivity.java
@Override public void onSensorSelected(Sensor s) { mgr.unregisterListener(log); mgr.registerListener(log, s, SensorManager.SENSOR_DELAY_NORMAL); log.init(isXYZ(s)); panes.closePane(); }
From source file:com.developer.shade.sensors.SensorService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.v("Running onStart", "Starting SensorService Service ID: " + startId); senManager.registerListener(this, senManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); return START_STICKY; }
From source file:alaindc.crowdroid.SensorsIntentService.java
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); if (action.equals(Constants.INTENT_START_SENSORS)) { // Init throughput taken SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean(Constants.THROUGHPUT_TAKEN, false); editor.commit();//from w w w .j a v a 2 s . c o m // Configure sensors and eventlistener mSensorManager = (SensorManager) getApplicationContext().getSystemService(Context.SENSOR_SERVICE); List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL); for (Sensor sensor : sensorList) { if (Constants.isInMonitoredSensors(sensor.getType())) mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL); } // TODO STUB: Comment this in release for (int type : Constants.STUBBED_MONITORED_SENSORS) { stub_onSensorChanged(type); } } if (action.equals(Constants.INTENT_START_AUDIOAMPLITUDE_SENSE)) { // Configure amplitude and start TEST amplitudeTask = new GetAmplitudeTask(this); amplitudeTask.getData(); } if (action.equals(Constants.INTENT_STUB_SENSOR_CHANGED + Sensor.TYPE_AMBIENT_TEMPERATURE)) { stub_onSensorChanged(intent.getIntExtra(Constants.INTENT_STUB_SENSOR_CHANGED_TYPE, -1)); } if (action.equals(Constants.INTENT_STUB_SENSOR_CHANGED + Sensor.TYPE_PRESSURE)) { stub_onSensorChanged(intent.getIntExtra(Constants.INTENT_STUB_SENSOR_CHANGED_TYPE, -1)); } if (action.equals(Constants.INTENT_STUB_SENSOR_CHANGED + Sensor.TYPE_RELATIVE_HUMIDITY)) { stub_onSensorChanged(intent.getIntExtra(Constants.INTENT_STUB_SENSOR_CHANGED_TYPE, -1)); } if (action.equals(Constants.INTENT_RECEIVED_AMPLITUDE)) { double amplitude = intent.getDoubleExtra(Constants.EXTRA_AMPLITUDE, -1); if (amplitude > 0) { SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(Constants.PREF_SENSOR_ + Constants.TYPE_AMPLITUDE, Double.toString(amplitude)); editor.commit(); // Update view Intent senseintent = new Intent(Constants.INTENT_UPDATE_SENSORS); senseintent.putExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA, "Sensor " + Constants.getNameOfSensor(Constants.TYPE_AMPLITUDE) + " value: " + Double.toString(amplitude)); LocalBroadcastManager.getInstance(this).sendBroadcast(senseintent); } int index = Constants.getIndexAlarmForSensor(Constants.TYPE_AMPLITUDE); // Set the alarms for next sensing of amplitude alarmMgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Intent intentAlarm = new Intent(getApplicationContext(), SensorsIntentService.class); intentAlarm.setAction(Constants.INTENT_START_AUDIOAMPLITUDE_SENSE); alarmIntent = PendingIntent.getService(getApplicationContext(), 0, intentAlarm, 0); // TIMEOUT for another monitoring of audio int seconds = 30; // TODO: De-hardcode this alarmMgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + seconds * 1000, alarmIntent); } } }