Pergunta

In my app, I have a service that is constantly running in the background, in time ranges the user determines.

In theory, I need to constantly know the user's distance from some destination. So for optimizations, I'm implementing my own proximity alert, which sleeps for time frames according to the current distance.

Moreover, if the user is not in motion at all, I could stop the locations updates, since I know it's not moving. For this I used a listener to the acceleration sensor. But leaving it on for long ranges of time is draining the battery, since minor updates arrive constantly.

I know I could increase the time frames of the locationing (I read the great article in Android Developers..), but it's highly risky for the correctness.

Did any one ever face a similar problem? Could you suggest a different designing?

Thanks for any help

Foi útil?

Solução

Android KitKat adds a new sensor type, TYPE_SIGNIFICANT_MOTION, which is designed to solve this problem. If supported, this causes the motion sensor to only wake the system for motion events that are significant enough to cause a location change.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top