Mouvre
Mouvre

Reputation: 274

How to use infrared sensor in Android-studio?

I have Xiaomi MI smartphone and it has infrared sensor. I am interested, how can I get access to sensor's class and which methods it's class has. I tried to find the information on other resources, but with no results.

Upvotes: 1

Views: 1728

Answers (1)

The_Martian
The_Martian

Reputation: 3767

You have to use

SensorManager

. There is a method called

getSensorList(int type)

that you can use to check all the sensors a certain device has. For example you can do similar to the following

  SensorManager mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
  Sensor mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

See this for a detailed description of Sensors.

Upvotes: 1

Related Questions