List of usage examples for android.content Context SENSOR_SERVICE
String SENSOR_SERVICE
To view the source code for android.content Context SENSOR_SERVICE.
Click Source Link
From source file:MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mImageViewCompass = (ImageView) findViewById(R.id.imageViewCompass); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); }
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;/* w ww . ja v a 2s. c o 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:com.commonsware.android.sensor.monitor.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mgr = (SensorManager) getSystemService(Context.SENSOR_SERVICE); log = (SensorLogFragment) getFragmentManager().findFragmentById(R.id.log); panes = (SlidingPaneLayout) findViewById(R.id.panes); panes.openPane();// w w w . j a va2s. c om }
From source file:org.mozilla.mozstumbler.service.stumblerthread.motiondetection.LegacyMotionSensor.java
public LegacyMotionSensor(Context ctx) { mAppContext = ctx; mSensorManager = (SensorManager) mAppContext.getSystemService(Context.SENSOR_SERVICE); }
From source file:it.unime.mobility4ckan.MySensor.java
public MySensor(Context context) { //super(context); mContext = context;//from ww w . j ava 2s . c o m sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); currentAcceleration = new float[3]; currentGyroscope = new float[3]; currentMagnetic = new float[3]; currentRotation = new float[3]; currentGravity = new float[3]; currentLinearAcceleration = new float[3]; /*tempSensor = sensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE); pressureSensor = sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE); lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); registerTempSensor(); registerPressureSensor(); registerLightSensor(); */ }
From source file:at.amartinz.hardware.sensors.BaseSensor.java
public static boolean isSupported(final Context context, final int type) { return ((SensorManager) context.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(type) != null; }
From source file:uk.ac.horizon.ubihelper.service.channel.SensorChannel.java
public SensorChannel(String name, Service service, Sensor sensor) { super(name);//from w ww . j av a2s. c o m mSensorManager = (SensorManager) service.getSystemService(Context.SENSOR_SERVICE); mSensor = sensor; }
From source file:org.namelessrom.devicecontrol.device.DeviceInformationSensorFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); addPreferencesFromResource(R.xml.device_information_sensor); final SensorManager sensorManager = (SensorManager) Application.get() .getSystemService(Context.SENSOR_SERVICE); // Sensors/*from ww w .ja v a 2s. c o m*/ PreferenceCategory category = (PreferenceCategory) findPreference("sensors"); // we need an array list to be able to sort it, a normal list throws // java.lang.UnsupportedOperationException when sorting final ArrayList<Sensor> sensorList = new ArrayList<>(sensorManager.getSensorList(Sensor.TYPE_ALL)); Collections.sort(sensorList, new SortIgnoreCase()); for (final Sensor s : sensorList) { addPreference(category, "", s.getName(), s.getVendor()); } if (category.getPreferenceCount() == 0) { getPreferenceScreen().removePreference(category); } }
From source file:org.apache.cordova.TempListener.java
/** * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * * @param cordova The context of the main Activity. *//*from w w w. j av a 2 s. c o m*/ public void setContext(CordovaInterface cordova) { super.setContext(cordova); this.sensorManager = (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE); }
From source file:eu.intermodalics.tango_ros_streamer.ImuNode.java
public ImuNode(Activity activity) { mSensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE); mRotationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); mGyroscopeSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); mAccelerometerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); }