You are right:
private static final int WAKE_UP_DELAY = 5000;
private static final int WAKE_UP_CALL = 0;
private Handler handler;
handler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
if (msg.what==WAKE_UP_CALL) {
// change message, your code goes here...
handler.sendMessageDelayed(handler.obtainMessage(WAKE_UP_CALL),
WAKE_UP_DELAY);
return true;
}
return false;
}
}
);
handler.sendMessageDelayed(handler.obtainMessage(WAKE_UP_CALL),
WAKE_UP_DELAY);
// do something...
Emanuel Moecklin
1gravity LLC
On Dec 1, 4:47 am, Doug <[email protected]> wrote:
> On Nov 30, 7:50 am, Emanuel Moecklin <[email protected]> wrote:
>
> > I would recommend using something like:
>
> This was actually unnecessarily complex. There's no need to post a
> whole new runnable to a handler that, in turn, sends a message to the
> same handler. You can just send the delayed message to the handler
> and you're done.
>
> Doug
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en