List of usage examples for android.hardware Sensor TYPE_ALL
int TYPE_ALL
To view the source code for android.hardware Sensor TYPE_ALL.
Click Source Link
From source file:Main.java
@SuppressWarnings("deprecation") public static String getSensorTypeStr(int type) { switch (type) { case Sensor.TYPE_ALL://-1 return "TYPE_ALL"; //Accelerometer sensor type case Sensor.TYPE_ACCELEROMETER://1 return "TYPE_ACCELEROMETER"; //Magnetic field sensor type case Sensor.TYPE_MAGNETIC_FIELD://2 return "TYPE_MAGNETIC_FIELD"; //Orientation sensor type case Sensor.TYPE_ORIENTATION://3 return "TYPE_ORIENTATION"; //Gyroscope sensor type case Sensor.TYPE_GYROSCOPE://4 return "TYPE_GYROSCOPE"; //Light sensor type case Sensor.TYPE_LIGHT://5 return "TYPE_LIGHT"; //Pressure sensor type case Sensor.TYPE_PRESSURE://6 return "TYPE_PRESSURE"; //Temperature sensor type case Sensor.TYPE_TEMPERATURE://7 return "TYPE_TEMPERATURE"; //Proximity sensor type case Sensor.TYPE_PROXIMITY://8 return "TYPE_PROXIMITY"; //Gravity sensor type case Sensor.TYPE_GRAVITY://9 return "TYPE_GRAVITY"; //Linear acceleration sensor type case Sensor.TYPE_LINEAR_ACCELERATION://10 return "TYPE_LINEAR_ACCELERATION"; //Rotation vector sensor type case Sensor.TYPE_ROTATION_VECTOR://11 return "TYPE_ROTATION_VECTOR"; //Relative humidity sensor type case Sensor.TYPE_RELATIVE_HUMIDITY://12 return "TYPE_RELATIVE_HUMIDITY"; //Ambient temperature sensor type case Sensor.TYPE_AMBIENT_TEMPERATURE://13 return "TYPE_AMBIENT_TEMPERATURE"; //Uncalibrated magnetic field sensor type case Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED://14 return "TYPE_MAGNETIC_FIELD_UNCALIBRATED"; //Uncalibrated rotation vector sensor type case Sensor.TYPE_GAME_ROTATION_VECTOR://15 return "TYPE_GAME_ROTATION_VECTOR"; //Uncalibreted gyroscope sensor type case Sensor.TYPE_GYROSCOPE_UNCALIBRATED://16 return "TYPE_GYROSCOPE_UNCALIBRATED"; //Significant motion trigger sensor case Sensor.TYPE_SIGNIFICANT_MOTION://17 return "TYPE_SIGNIFICANT_MOTION"; //Step detector sensor case Sensor.TYPE_STEP_DETECTOR://18 return "TYPE_STEP_DETECTOR"; //Step counter sensor case Sensor.TYPE_STEP_COUNTER://19 return "TYPE_STEP_COUNTER"; //Geo-magnetic rotation vector case Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR://20 return "TYPE_GEOMAGNETIC_ROTATION_VECTOR"; //Heart rate monitor case Sensor.TYPE_HEART_RATE://21 return "TYPE_HEART_RATE"; default:// w ww. j av a 2 s . com return UNKNOWN; } }
From source file:Main.java
public static List<Sensor> getAllSensors() { return sensorManager.getSensorList(Sensor.TYPE_ALL); }
From source file:MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView listView = (ListView) findViewById(R.id.list); List sensorList = new ArrayList<String>(); List<Sensor> sensors = ((SensorManager) getSystemService(Context.SENSOR_SERVICE)) .getSensorList(Sensor.TYPE_ALL); for (Sensor sensor : sensors) { sensorList.add(sensor.getName()); }/*w w w. j a v a2 s . c o m*/ ListAdapter sensorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, sensorList); listView.setAdapter(sensorAdapter); }
From source file:altermarkive.uploader.Report.java
@SuppressWarnings("unused") public static String probe(Context context) throws JSONException { SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); List<Sensor> list = manager.getSensorList(Sensor.TYPE_ALL); int[] types = new int[list.size()]; String[] vendors = new String[list.size()]; String[] names = new String[list.size()]; float[] resolutions = new float[list.size()]; int[] delays = new int[list.size()]; float[] ranges = new float[list.size()]; float[] powers = new float[list.size()]; int i = 0;//w w w . java2s . co m for (Sensor sensor : list) { types[i] = sensor.getType(); vendors[i] = sensor.getVendor(); names[i] = sensor.getName(); resolutions[i] = sensor.getResolution(); delays[i] = sensor.getMinDelay(); ranges[i] = sensor.getMaximumRange(); powers[i] = sensor.getPower(); i++; } return report(context, types, vendors, names, resolutions, delays, ranges, powers); }
From source file:org.jitsi.android.gui.fragment.ProximitySensorFragment.java
/** * {@inheritDoc}/*ww w . j a v a2s . c o m*/ */ @Override public void onResume() { super.onResume(); // Skips if the sensor has been already attached if (proximitySensor != null) return; SensorManager manager = JitsiApplication.getSensorManager(); List<Sensor> sensors = manager.getSensorList(Sensor.TYPE_ALL); logger.trace("Device has " + sensors.size() + " sensors"); for (Sensor s : sensors) { logger.trace("Sensor " + s.getName() + " type: " + s.getType()); } this.proximitySensor = manager.getDefaultSensor(Sensor.TYPE_PROXIMITY); if (proximitySensor == null) { return; } logger.info("Using proximity sensor: " + proximitySensor.getName()); sensorDisabled = false; manager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_UI); }
From source file:ch.bfh.sensordataprocessor.sensor.SensorSelectorFragment.java
/** * connect with a display fragment to call later when user clicks a sensor * name, also setup the ListAdapter to show all the Sensors *//*from w w w. jav a 2s .co m*/ public void setSensorDisplay(SensorDisplayFragment sensorDisplay) { this.sensorDisplay = sensorDisplay; SensorManager sensorManager = (SensorManager) getActivity().getSystemService(Activity.SENSOR_SERVICE); List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ALL); this.setListAdapter(new SensorListAdapter(getActivity().getApplicationContext(), android.R.layout.simple_list_item_1, sensors)); }
From source file:org.jitsi.android.gui.call.ProximitySensorFragment.java
/** * {@inheritDoc}/*from www .ja v a 2 s. c o m*/ */ @Override public void onResume() { super.onResume(); SensorManager manager = JitsiApplication.getSensorManager(); // Skips if the sensor has been already attached if (proximitySensor != null) { // Re-registers the listener as it might have been // unregistered in onPause() manager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_UI); return; } List<Sensor> sensors = manager.getSensorList(Sensor.TYPE_ALL); logger.trace("Device has " + sensors.size() + " sensors"); for (Sensor s : sensors) { logger.trace("Sensor " + s.getName() + " type: " + s.getType()); } this.proximitySensor = manager.getDefaultSensor(Sensor.TYPE_PROXIMITY); if (proximitySensor == null) { return; } logger.info("Using proximity sensor: " + proximitySensor.getName()); sensorDisabled = false; manager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_UI); }
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 w w w . j a 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:com.commonsware.android.sensor.monitor.MainActivity.java
@Override public List<Sensor> getSensorList() { List<Sensor> unfiltered = new ArrayList<Sensor>(mgr.getSensorList(Sensor.TYPE_ALL)); List<Sensor> result = new ArrayList<Sensor>(); for (Sensor s : unfiltered) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || !isTriggerSensor(s)) { result.add(s);// w w w .jav a 2s. c o m } } Collections.sort(result, new Comparator<Sensor>() { @Override public int compare(final Sensor a, final Sensor b) { return (a.toString().compareTo(b.toString())); } }); return (result); }
From source file:com.tritop.androsense2.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ((AndrosensApp) this.getApplication()) .setSensorManager((SensorManager) getSystemService(Context.SENSOR_SERVICE)); ((AndrosensApp) getApplication())// w ww . j av a 2 s . c om .setSensorList(((AndrosensApp) getApplication()).getSensorManager().getSensorList(Sensor.TYPE_ALL)); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(this); }