Skip to main content

Accelerometer

Accelerometer

An accelerometer is a device that measures the proper acceleration of an object. Proper acceleration is the acceleration (the rate of change of velocity) of the object relative to an observer who is in free fall (that is, relative to an inertial frame of reference).

To get started using it, you must use KmpAccelerometer. To subscribe to changes to the device's orientation, we invoke the startListening function. We can then process the results in our app.


_5
KmpAccelerometer.startListening {
_5
val x = it.first
_5
val y = it.second
_5
val z = it.third
_5
}

To stop listening to acc changes, we use the function stopListening. It's important to deactivate the listener, so the component doesn't continue to broadcast acc data changes to our app.


_1
KmpAccelerometer.stoplistening()

Any Setup Required?

None