public class Lifecycle
- Object
- Lifecycle
Optional helper class that implements the Codename One lifecycle methods with reasonable default
implementations to help keep sample code smaller.
Constructors
public Lifecycle() |
Methods
public void init(Object context) | Invoked when the app is “cold launched”, this acts like a constructor |
protected void bindCrashProtection() | Callback that can be overriden to disable or modify crash protection |
protected int getNetworkThreadCount() | Returns the default number of network thread count |
protected String getThemeName() | Returns the name of the global theme file, by default it’s “/theme”. |
public Resources getTheme() | The theme instance |
protected void handleNetworkError(NetworkEvent err) | Invoked on a network error callback |
public void start() | Default start callback that’s invoked on application resume |
public void runApp() | This method is invoked by start to show the first form of the application |
public void stop() | Callback when the app is suspended |
public void destroy() | Callback when the app is destroyed |
public void onReceivedSharedContent(SharedContent content) | Invoked when the app is launched or resumed because the user shared content (text, a URL, a file or an image) into it from another application. |
protected Form getCurrentForm() | Returns the form currently stored by this Lifecycle instance for application resume handling. |
protected void setCurrentForm(Form current) | The current form within the application lifecycle which possibly differs from the one in the implementation |
Inherited methods
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
contextObject- 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
errNetworkEvent- 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()Returns the form currently stored by this Lifecycle instance for
application resume handling.
In most application code, use CN.getCurrentForm() instead, as it returns
the form that is actually displayed on the screen. This method is only useful
when subclassing Lifecycle and you need to inspect or customize the form
remembered by stop() and restored by start(), which may differ from the
form currently displayed by the Codename One implementation.
Returns
the form stored in this lifecycle, or
null if no form has been storedsetCurrentForm
protected void setCurrentForm(Form current)The current form within the application lifecycle which possibly differs from the one in the implementation
Parameters
currentForm- the new current Form