Class Lifecycle

java.lang.Object
com.codename1.system.Lifecycle

public class Lifecycle extends Object
Optional helper class that implements the Codename One lifecycle methods with reasonable default implementations to help keep sample code smaller.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Callback that can be overriden to disable or modify crash protection
    void
    Callback when the app is destroyed
    protected Form
    The current form within the application lifecycle which possibly differs from the one in the implementation
    protected int
    Returns the default number of network thread count
    The theme instance
    protected String
    Returns the name of the global theme file, by default it's "/theme".
    protected void
    Invoked on a network error callback
    void
    init(Object context)
    Invoked when the app is "cold launched", this acts like a constructor
    void
    This method is invoked by start to show the first form of the application
    protected void
    The current form within the application lifecycle which possibly differs from the one in the implementation
    void
    Default start callback that's invoked on application resume
    void
    Callback when the app is suspended

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Lifecycle

      public Lifecycle()
  • Method Details

    • init

      public void init(Object context)

      Invoked when the app is "cold launched", this acts like a constructor

      Parameters
      • context: some OSs might pass a native object representing platform internal information
    • bindCrashProtection

      protected void bindCrashProtection()
      Callback that can be overriden to disable or modify crash protection
    • getNetworkThreadCount

      protected int getNetworkThreadCount()

      Returns the default number of network thread count

      Returns

      currently two threads

    • getThemeName

      protected String getThemeName()

      Returns the name of the global theme file, by default it's "/theme". Can be overriden by subclasses to load a different file name

      Returns

      "/theme"

    • getTheme

      public Resources getTheme()

      The theme instance

      Returns

      the theme

    • handleNetworkError

      protected void handleNetworkError(NetworkEvent err)

      Invoked on a network error callback

      Parameters
      • err: the network error event
    • start

      public void start()
      Default start callback that's invoked on application resume
    • runApp

      public void runApp()
      This method is invoked by start to show the first form of the application
    • stop

      public void stop()
      Callback when the app is suspended
    • destroy

      public void destroy()
      Callback when the app is destroyed
    • getCurrentForm

      protected Form getCurrentForm()
      The current form within the application lifecycle which possibly differs from the one in the implementation
    • setCurrentForm

      protected void setCurrentForm(Form current)

      The current form within the application lifecycle which possibly differs from the one in the implementation

      Parameters
      • current: the new current Form