Several internal sensors of the same type

The Android SensorManager class will return a list of sensors of a specific type. I am wondering if the device had, for example, multiple internal temperature sensors (TYPE_AMBIENT_TEMPERATURE), how can I differentiate between them? Would Sensor.getName () and Sensor.getVendor () be everything I would have to work with?

+3


source to share


1 answer


you can getSensorList

get all sensors of a specific type, but then you need to use the methods you mentioned if you want a specific sensor.

even the implementation getDefaultSensor

just returns the first one from the list



public Sensor getDefaultSensor(int type) {
     // TODO: need to be smarter, for now, just return the 1st sensor
     List<Sensor> l = getSensorList(type);
     return l.isEmpty() ? null : l.get(0);
}

      

+1


source







All Articles