¿Cómo puedo mantener un temporizador funcionando cuando se llama a onPause() en mi aplicación de Android?
Frecuentes
Visto 534 veces
0
I am making a running app. A timer starts when i start a run. My activity starts from beginning when i unlock my phone screen. I know that i can save my objects state using onSaveInstanceState() but How can i keep the timer running when my phone screen is locked? Whats the best way to do that? Thanks in advance.
1 Respuestas
2
Best solution depends on what are you planning to do. You can create a service with that timer, which will continue running even after onPause(). Or if you need it just to know how much time has elapsed, I would reccomend creating a timestamp at the start of run and comparing it ti current time whenever you need.
Respondido 28 ago 12, 11:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android android-intent android-activity android-service android-lifecycle or haz tu propia pregunta.
Use a Service for that. That Service will be called from your Activity . - Carnal