I have a question while studying Android.
Is there a way to continuously measure the sensor (acceleration) even if the app presses the home key to pause? Do I have to use the service?
android application
If you do not call unregisterListener()
separately, you can still get the sensor value even if it is pause. However, since it will cause battery consumption, it is recommended to use an unregisterListener() at the time of pause. Also, turning off the screen does not disable the sensor on the system.
Always make sure to disable sensors you don't need, especially when your activity is paused. Failing to do so can drain the battery in just a few hours. Note that the system will not disable sensors automatically when the screen turns off.
© 2024 OneMinuteCode. All rights reserved.