I want to know how to implement a count down timer running on the screen. Its needed in OTP screen say for example , i implemented with nor timer from view model and passing the value change from onTIck() to the state of composable. But the issue here , when the timer is running , if we lock the device and unlock it the timer resets instead of running in the background.How to make it run in the background and update the new value when the device is unlocked and the app is opened.
CodePudding user response:
You could make a background timer using AlarManager
and BroadcastReceiver
in Kotlin.
Please take a look at here