|
postMain()
method, pass the Form
parameter to Timer.schedule()
. Getting the Form via
other mechanisms doesn't work.
postMain()
is the auto-generated helper method called
immediately after your Main
form has been displayed. If
you want to start a timer when a different form is shown, override the
desired postXXX
method.
In postMain()
, if you have created a timer (using
new UITimer()
, for example), you'll then want to start it
using timer.schedule()
. The third parameter is a
Form
. Be sure to pass in the one passed to
postMain()
as the first parameter.
@Override protected void postMain(Form form) { [...] timer.schedule(1000, true, form); // WorksIf you try to use
Display.getInstance().getCurrent()
, you'll find your
timer doesn't start sometimes since Display still has the old form.
(This is at least an undocumented behavior, at worst a bug in CN1.)
@Override protected void postMain(Form form) { [...] timer.schedule(1000, true, Display.getInstance().getCurrent()); // AVOID -- doesn't work
Copyright © 2024 Andrew Oliver