I have now noticed a radical change in the source Java code obtained via https://start.codenameone.com/
Obviously I'm used to coding with init(), start(), stop(), destroy() methods, I don't know how to handle this new code. Is it documented somewhere? I didn't see anything in the blog. Thank you
Lifecycle's javadoc (https://www.codenameone.com/javadoc/com/codename1/system/Lifecycle.html) is not very helpful. It just states:
Optional helper class that implements the Codename One lifecycle methods with reasonable default implementations to help keep sample code smaller.
So the following code is just an example that I need to remove, and then manually insert the usual init(), start(), stop() and destroy() methods?
public class MyDownloader extends Lifecycle {
@Override
public void runApp() {
Form hi = new Form("Hi World", BoxLayout.y());
Button helloButton = new Button("Hello World");
hi.add(helloButton);
helloButton.addActionListener(e -> hello());
hi.getToolbar().addMaterialCommandToSideMenu("Hello Command",
FontImage.MATERIAL_CHECK, 4, e -> hello());
hi.show();
}
private void hello() {
Dialog.show("Hello Codename One", "Welcome to Codename One", "OK", null);
}
}