Example usage for android.hardware Sensor getName

List of usage examples for android.hardware Sensor getName

Introduction

In this page you can find the example usage for android.hardware Sensor getName.

Prototype

public String getName() 

Source Link

Usage

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;//  www .  ja  v  a  2s .  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: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());
    }//from  w ww.  j a  v  a 2  s  . c  o m
    ListAdapter sensorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, sensorList);
    listView.setAdapter(sensorAdapter);

}

From source file:com.tritop.androsense2.fragments.SensorsListFragment.java

private List<Map<String, String>> parseAvailableSensors(List<Sensor> sList) {
    List<Map<String, String>> mList = new Vector<Map<String, String>>();
    HashMap<String, String> mSensorInfo;
    for (Sensor sensor : sList) {
        Log.d("SENSORLIST", sensor.getName());
        mSensorInfo = new HashMap<String, String>();
        mSensorInfo.put(SENSOR_KEY_NAME, sensor.getName());
        mSensorInfo.put(SENSOR_KEY_VENDOR, sensor.getVendor());
        mSensorInfo.put(SENSOR_KEY_VERSION, SensorInfo.getStringType(getActivity(), sensor.getType()) + " v"
                + String.valueOf(sensor.getVersion()));
        mSensorInfo.put(SENSOR_KEY_POWER, SensorInfo.formatSensorfloat(sensor.getPower(), 4) + " mA");
        mSensorInfo.put(SENSOR_KEY_MAXRANGE,
                SensorInfo.formatSensorfloat(sensor.getMaximumRange(), 3) + " max");
        mSensorInfo.put(SENSOR_KEY_RESOLUTION,
                SensorInfo.formatSensorfloat(sensor.getResolution(), 4) + " res");
        mList.add(mSensorInfo);//from   ww  w .  j a va  2 s .com
    }
    return mList;

}

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  ww  .ja  v a 2 s.  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.durka.hallmonitor.ViewCoverProximityService.java

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
    // I don't care
    Log.d(LOG_TAG + ".oAC", "Sensor=" + sensor.getName() + ", accuracy=" + accuracy);
}

From source file:rus.cpuinfo.AndroidDepedentModel.SensorsInfo.java

@NonNull
private String getSensorName(final int type) {
    Sensor sensor = mSensorManager.getDefaultSensor(type);
    return sensor == null ? StringUtils.EMPTY : sensor.getName();
}

From source file:org.jitsi.android.gui.fragment.ProximitySensorFragment.java

/**
 * {@inheritDoc}/*ww w.j a v a  2 s. 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:com.tritop.androsense2.fragments.SensorsList.java

private List<Map<String, String>> parseAvailableSensors(List<Sensor> sList) {
    List<Map<String, String>> mList = new Vector<Map<String, String>>();
    HashMap<String, String> mSensorInfo;
    for (Sensor sensor : sList) {
        mSensorInfo = new HashMap<String, String>();
        mSensorInfo.put(SENSOR_KEY_NAME, sensor.getName());
        mSensorInfo.put(SENSOR_KEY_VENDOR, sensor.getVendor());
        mSensorInfo.put(SENSOR_KEY_VERSION, SensorInfo.getStringType(getActivity(), sensor.getType()) + " v"
                + String.valueOf(sensor.getVersion()));
        mSensorInfo.put(SENSOR_KEY_POWER, SensorInfo.formatSensorfloat(sensor.getPower(), 4) + " mA");
        mSensorInfo.put(SENSOR_KEY_MAXRANGE,
                SensorInfo.formatSensorfloat(sensor.getMaximumRange(), 3) + " max");
        mSensorInfo.put(SENSOR_KEY_RESOLUTION,
                SensorInfo.formatSensorfloat(sensor.getResolution(), 4) + " res");
        mList.add(mSensorInfo);/*from   w  ww . j a va 2  s .c  om*/
    }
    return mList;

}

From source file:org.namelessrom.devicecontrol.modules.device.sensors.BaseSensor.java

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
    Logger.d(this, "onAccuracyChanged: %s (%s), %s", sensor.getName(), sensor.getVendor(), accuracy);
}

From source file:com.developer.shade.sensors.SensorService.java

@Override
public void onCreate() {
    Log.d("Running onCreate", "Obtaining Device Accelerometer Hardware Sensor");
    senManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    Sensor sensor = senManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    Log.d("NAME: ", sensor.getName());
    initNotification();/*from  www.  ja  v  a2  s  . c  om*/
    super.onCreate();
}