Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Write safe initialization code

by Retired on ‎02-16-2010 10:14 AM - edited on ‎03-24-2011 11:27 AM by BlackBerry Development Advisor (9,608 Views)



This article applies to the following:

  • BlackBerry® smartphones based on Java® technology running BlackBerry® Device Software 4.0 and later



An application may need to run once automatically during system start-up to perform initialization routines such as registering listeners and retrieving information from persistent storage.


Such routines should not be performed until the system has finished core start-up tasks such as security checks, establishing network connectivity, and other tasks.


Therefore an application should ensure that system start-up is complete before running its own initialization code, as demonstrated in the following example:



import net.rim.device.api.system.*;

// application that automatically runs on system startup
class MyApp extends Application implements SystemListener {

public static void main(String [] args) {

MyApp appInstance = new MyApp();

// If system startup is still in progress when this
// application is run.
if (ApplicationManager.getApplicationManager().inStartup()) {
} else {

// constructs
MyApp() {}

private void doStartupWorkLater() {
invokeLater(new Runnable() {
public void run() {

private void doStartupWork() {


// SystemListener

/** @see SystemListener#powerUp() */
public void powerUp() {

// TODO: other SystemListener methods



by Developer
on ‎03-21-2011 12:53 PM
class MyApp extends UiApplication implements SystemListener {

I think your code is missing the highlighted addition - please fix.

by BlackBerry Development Advisor
on ‎03-24-2011 11:28 AM

Yes, extends Application should be there.  I'll fix this up.

Users Online
Currently online: 38 members 2,032 guests
Please welcome our newest community members: