2

I have been using this algorithm - (how to calculate exact foot step count using accelerometer in android?) to calculate the number of steps taken. I unregister the sensor manager listener in the onPause() method of my activity.

mSensorManager.unregisterListener(this);

When the phone's screen is off, my steps aren't counted. How do I count the steps using the accelerometer even when the phone's screen is switched off? Please guide me.

1 Answer 1

2

You should read about the activity lifecycle first. The onPause method is called when the screen turns off, so you are not listening when the screen is off. You could instead use a background service to listen continuously to the accelerometer sensor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.