[android-developers] Stop watch functionality in Android
Hi,
-- I want to implement something like Stopwatch functionality.,
When the user clicks on a Start button, I want to start the stopwatch which shows the hr:min:sec in textview and keep on updates it,
and when the user clickis on button Stop, then timer needs to be stop.
Even if the user starts the Stopwatch and keep the application in background by pressing home, after sometime if
the user comes to application eventhough the timer should keep run until the user clicks on Stop button.
Can anyone give me suggestions or best approach to implement this functionality.
I tried with Timer and TimerTask but when I click on Home after some time If I comeback to app the timer text is not updating and its showing as empty.
Timer travelTimer = new Timer();
travelTimer.schedule(new TimerTask() {
@SuppressLint("SimpleDateFormat")
@Override
public void run() {
----
-------------------------
}
}, 0, 1000);
Is the reason when the app goes to background, the android system is killing the Timer.. ?
Please give me the suggestion.
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home