Time for action – processing the sensor values in the background service

There will be cases where your app needs to listen and process the sensor values in the background. Such cases cannot be handled using the activity code structure. We need to use the Android service to handle background sensor processing. Let's discuss the background processing scenario with an example.

The phone handling algorithm

In our example, we will be playing a small MP3 sound when somebody picks up or handles the phone. We will call this event the phone handling event, and we will use the Android background service to continuously process the gyroscope sensor values to detect this phone-handling event. The gyroscope gives the rate of rotation of the phone in each

Get Android Sensor Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.