April 2016
Intermediate to advanced
194 pages
4h 37m
English
In this section, we will explore how to use sensors in the activity. This is the most basic and straightforward way of using sensors. Also, it's the most efficient way if your sensor functionality only ties to that activity:
SensorEventListener interface so that our activity can receive SensorEvent through the onSensorChanged() method. The following code snippet shows the necessary import statements and the class declaration:import android.app.Activity; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; ...