views:

29

answers:

2

I'm attempting to create an incredibly simple widget that changes the text displayed every 5s or so. However I've had major headaches attempting to get this to work. Obviously I can't use the onUpdate call as it's a minimum of every 30min. Currently my solution uses an Timer in an extended Service class, which is as ugly as hell and tends to run like a dog after a while. Is there a "clean" way of doing this, ie. in a manner that doesn't require a Widget, UpdateService, Timers etc.

I'm not asking for an entire solution, just a pointer as to how to go about doing this in an efficient manner.

Thanks, John

A: 

you might want to look into timer tasks, thanks

SoftReference
A: 

Use a CountdownTimer:

 new CountdownTimer(5000, 1000) {

     public void onTick(long millisUntilFinished) {
         mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
     }

     public void onFinish() {
         mTextField.setText("done!");
     }
  }.start();
fredley