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:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns all the sensors available on the device as a List *//* ww w. j a v a 2s .com*/ public void getAllSensors() { SensorManager sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); List<Sensor> list = sm.getSensorList(Sensor.TYPE_ALL); if (CommonUtilities.DEBUG_MODE_ENABLED) { for (Sensor s : list) { Log.d("SENSORS", s.getName()); } } }
From source file:org.wheelmap.android.fragment.POIsOsmdroidFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);/*from ww w .j av a2 s . c o m*/ tileUrl = String.format(baseUrl, getString(string.mapbox_key)); mMapBoxTileSource = new XYTileSource("Mapbox", null, 3, 21, 256, ".png", new String[] { tileUrl }); mBus = EventBus.getDefault(); mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); // noinspection deprecation mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); mOrientationAvailable = mSensor != null; attachWorkerFragment(); retrieveInitialLocation(); }
From source file:com.nextgis.maplibui.fragment.CompassFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (null == getParentFragment()) { setRetainInstance(true);//ww w. j a v a 2 s. c o m } // reference to vibrator service mDeclination = 0; mVibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); if (!PermissionUtil.hasPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) || !PermissionUtil.hasPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION)) return; 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); } } if (mCurrentLocation != null) mDeclination = getDeclination(mCurrentLocation, System.currentTimeMillis()); }
From source file:com.davidmascharka.lips.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestMyPermissions();/* w ww . j a va 2 s .c o m*/ } getPreferences(); setContentView(R.layout.activity_main); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction().add(R.id.container, new MainFragment()).commit(); } rotation = new float[9]; inclination = new float[9]; orientation = new float[3]; sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { updateLocation(location); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } }; wifiReadings = new LinkedHashMap<String, Integer>(); resetWifiReadings(building); userInitiatedScan = false; }
From source file:com.example.administrator.myapplication2._2_exercise._2_Status_heart.fragments.LeftFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout._2_status_heart, container, false); SharedPreferences myPrefs = getActivity().getSharedPreferences("alert", Context.MODE_PRIVATE); if ((myPrefs != null) && (myPrefs.contains("alert"))) { alert = myPrefs.getBoolean("alert", false); }/* www . jav a 2 s. c o m*/ mTextChat = (TextView) rootView.findViewById(R.id.text_chat); mTextChat.setMaxLines(1000); mTextChat.setVerticalScrollBarEnabled(true); mTextChat.setMovementMethod(new ScrollingMovementMethod()); //mEditChat = (EditText) rootView.findViewById(R.id.edit_chat); //mEditChat.setOnEditorActionListener(mWriteListener); mBtnSend = (Button) rootView.findViewById(R.id.button_send); mBtnSend.setOnClickListener(this); handler = new MyHandler(); progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar2); new Thread() { @Override public void run() { try { while (true) { sleep(1000); handler.sendMessage(new Message()); if (threadBool == false) { break; } } } catch (InterruptedException e) { e.printStackTrace(); } } }.start(); /*///////?//////////*/ heartRateList = new ArrayList<>(); tvTime = (TextView) rootView.findViewById(R.id.tvTime); ibPause = (ImageButton) rootView.findViewById(R.id.ibPause); ibStop = (ImageButton) rootView.findViewById(R.id.ibStop); ibPause.setOnClickListener(this); ibStop.setOnClickListener(this); m_display_run = new Runnable() { public void run() { // ? ? . tvTime.setText(m_display_string); } }; /*gps*/ // ? ? - mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); arrayPoints = new ArrayList<LatLng>(); arrayPoints_network = new ArrayList<LatLng>(); postJsonData1(); // ? startLocationService(); return rootView; }
From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.ColorimetryLiquidActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_colorimetry_liquid); setTitle("Analysis"); Intent intent = getIntent();//from ww w . j a v a2 s. c o m mIsCalibration = intent.getBooleanExtra("isCalibration", false); mSwatchValue = intent.getDoubleExtra("swatchValue", 0); sound = new SoundPoolPlayer(this); textDilution = (TextView) findViewById(R.id.textDilution); TextView textSubtitle = (TextView) findViewById(R.id.textSubtitle); //Set up the shake detector mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mShakeDetector = new ShakeDetector(new ShakeDetector.OnShakeListener() { @Override public void onShake() { if ((mIgnoreShake) || mWaitingForStillness || mCameraFragment == null) { return; } if (isDestroyed()) { return; } mWaitingForStillness = true; showError(String.format(TWO_SENTENCE_FORMAT, getString(R.string.errorTestInterrupted), getString(R.string.doNotMoveDeviceDuringTest)), null); } }, new ShakeDetector.OnNoShakeListener() { @Override public void onNoShake() { if (mWaitingForStillness) { mWaitingForStillness = false; dismissShakeAndStartTest(); } } }); mSensorManager.unregisterListener(mShakeDetector); mShakeDetector.setMinShakeAcceleration(5); mShakeDetector.setMaxShakeDuration(MAX_SHAKE_DURATION); textSubtitle.setText(R.string.placeDevice); }
From source file:edu.Groove9.TunesMaster.songplayer.SongPlayerFragment.java
private void setupShakeDetector() { // ShakeDetector initialization mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mShakeDetector = new ShakeDetector(); mShakeDetector.setOnShakeListener(new ShakeDetector.OnShakeListener() { @Override/*from ww w. ja v a2 s. c o m*/ public void onShake(int count) { mPresenter.shuffleSong(); Logger.get().log(new UserEvent(UserEvent.Source.Gesture, UserEvent.Action.Shuffle)); } }); }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.BusStopDetailsFragment.java
/** * {@inheritDoc}//from w w w . j ava 2s . c o m */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = getActivity().getApplicationContext(); // Get the various resources and services. bsd = BusStopDatabase.getInstance(context); sd = SettingsDatabase.getInstance(context); locMan = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); sensMan = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); accelerometer = sensMan.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); magnetometer = sensMan.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); stopCode = getArguments().getString(ARG_STOPCODE); hitboxSize = getResources().getDimensionPixelOffset(R.dimen.star_hitbox_size); }
From source file:edu.uwp.alga.calculator.CalculatorFragment.java
public void getLux() { sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); if (lightSensor == null) { lux = 12000f;/* w ww. ja v a 2 s .c o m*/ Log.e("Light", String.valueOf(lux)); } else { sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL); } }