List of usage examples for android.hardware Sensor getType
public int getType()
From source file:net.line2soft.preambul.controllers.SlippyMapListener.java
@Override public void onAccuracyChanged(Sensor sensor, int accuracy) { if (sensor.getType() == Sensor.TYPE_ORIENTATION) { CompassView cp = (CompassView) activity.findViewById(R.id.compass); CompassView cpBig = (CompassView) activity.findViewById(R.id.compassBig); if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE || accuracy == SensorManager.SENSOR_STATUS_ACCURACY_LOW) { activity.setAccurate(false); activity.displayInfo(activity.getString(R.string.message_compass_not_accurate)); cp.setVisibility(View.GONE); cpBig.setVisibility(View.GONE); } else {/*from ww w . ja v a2s . c o m*/ activity.setAccurate(true); if (cp.getVisibility() == View.GONE && cpBig.getVisibility() == View.GONE) { cp.setVisibility(View.VISIBLE); } } } }
From source file:org.dartlang.phonegap.barometer.BarometerListener.java
/** * Called when the accuracy of the sensor has changed. * * @param sensor/*from w w w.ja va 2s .co m*/ * @param accuracy */ public void onAccuracyChanged(Sensor sensor, int accuracy) { // Only look at barometer events if (sensor.getType() != Sensor.TYPE_PRESSURE) { return; } // If not running, then just return if (this.status == BarometerListener.STOPPED) { return; } this.accuracy = accuracy; }
From source file:org.skt.runtime.html5apis.Accelerometer.java
/** * Called when the accuracy of the sensor has changed. * /*from w w w . j a va2 s.c o m*/ * @param sensor * @param accuracy */ public void onAccuracyChanged(Sensor sensor, int accuracy) { // Only look at accelerometer events if (sensor.getType() != Sensor.TYPE_ACCELEROMETER) { return; } // If not running, then just return if (this.status == Accelerometer.STOPPED) { return; } this.accuracy = accuracy; }
From source file:org.dartlang.phonegap.thermometer.ThermometerListener.java
/** * Called when the accuracy of the sensor has changed. * * @param sensor// w w w . j ava2 s. co m * @param accuracy */ public void onAccuracyChanged(Sensor sensor, int accuracy) { // Only look at thermometer events if (sensor.getType() != Sensor.TYPE_AMBIENT_TEMPERATURE) { return; } // If not running, then just return if (this.status == ThermometerListener.STOPPED) { return; } this.accuracy = accuracy; }
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 www. j a v a 2 s . co 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); } } }
From source file:org.apache.cordova.AccelListener.java
/** * Called when the accuracy of the sensor has changed. * * @param sensor//from www . j a v a2s.c om * @param accuracy */ public void onAccuracyChanged(Sensor sensor, int accuracy) { // Only look at accelerometer events if (sensor.getType() != Sensor.TYPE_ACCELEROMETER) { return; } // If not running, then just return if (this.status == AccelListener.STOPPED) { return; } this.accuracy = accuracy; }
From source file:com.android.plugins.GyroscopeListener.java
/** * Called when the accuracy of the sensor has changed. * * @param sensor//from ww w . j av a2 s . c o m * @param accuracy */ public void onAccuracyChanged(Sensor sensor, int accuracy) { // Only look at gyroscope events if (sensor.getType() != Sensor.TYPE_GYROSCOPE) { return; } // If not running, then just return if (this.status == GyroscopeListener.STOPPED) { return; } this.accuracy = accuracy; }
From source file:io.github.data4all.service.OrientationListener.java
@Override public void onAccuracyChanged(Sensor sensor, int accuracy) { if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) { if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_HIGH) { Log.d(TAG, "The sensor: " + sensor.getName() + " has now the accuracy of " + accuracy + " it needs recalibration!"); accOk = accuracy;/*from w w w . j a v a2 s . c o m*/ } else { Log.d(TAG, "The sensor: " + sensor.getName() + " has now the accuracy of " + accuracy + " App ready to use!"); accOk = accuracy; } } if (sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_HIGH) { Log.d(TAG, "The sensor: " + sensor.getName() + " has now the accuracy of " + accuracy + " it needs recalibration!"); magOk = accuracy; } else { Log.d(TAG, "The sensor: " + sensor.getName() + " has now the accuracy of " + accuracy + " App ready to use!"); magOk = accuracy; } } this.checkAccuracy(); /* * Creates a new Intent containing a Uri object BROADCAST_ACTION is a * custom Intent action */ final Intent localIntent = new Intent(BROADCAST_CAMERA) // Puts the status into the Intent .putExtra(INTENT_CAMERA_UPDATE, true); // Broadcasts the Intent to receivers in this app. LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent); }
From source file:com.configurer.easyscreenlock.service.ForegroundSensorService.java
public void showAvailableSensors() { try {/*from www . j a va2 s. c o m*/ List<Sensor> list = mSensorManager.getSensorList(Sensor.TYPE_ALL); if (list != null) { Log.i(TAG, list.size() + " Available Sensors"); for (Sensor s : list) { Log.i(TAG, "Name : " + s.getName() + ", Type : " + s.getType()); } System.out.println("-done-"); } else { Log.w(TAG, "You have no sensors"); } } catch (Exception e) { Log.e(TAG, e.getMessage()); } }
From source file:org.apache.cordova.devicemotion.LightListener.java
/** * Called when the accuracy of the sensor has changed. * * @param sensor//from w w w . j a v a 2 s.c o m * @param accuracy */ public void onAccuracyChanged(Sensor sensor, int accuracy) { // Only look at accelerometer events if (sensor.getType() != Sensor.TYPE_LIGHT) { return; } // If not running, then just return if (this.status == LightListener.STOPPED) { return; } this.accuracy = accuracy; }