BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Display Dialog on startup (http://www.blackberryforums.com/developer-forum/149998-display-dialog-startup.html)

jrebeiro 09-13-2008 10:48 PM

Display Dialog on startup
 
I am having trouble with the following code. I am creating a background process and would like to display a Dialog on startup. Nothing ever gets displayed. I stepped through the code and made sure that Dialog.ask gets executed but still nothing shows.

In the emulator the Media Card Insterted dialog seems to takeover the screen and my dialog gets ignored.

Here is the code:

Code:

public class GVIntercepter extends UiApplication implements SystemListener
{
    public static void main(String[] args)
    {
        // register an options provider
        GVIntercepterOptionsProvider provider = new GVIntercepterOptionsProvider();
        OptionsManager.registerOptionsProvider(provider);
       
        // register a phone handler
        PhoneHandler phone_handler = new PhoneHandler();
        Phone.addPhoneListener(phone_handler);
       
        GVIntercepter instance = new GVIntercepter();
        // instance.enterEventDispatcher();
       
        if( ApplicationManager.getApplicationManager().inStartup() ) {
          // Add a system listener to detect when system is ready and available.
          instance.addSystemListener(instance);
        } else {
          // System is already ready and available so perform your start up work now.
          // Note that this work must be completed using invokeLater because the
          // application has not yet entered the event dispatcher.
          instance.doStartupWorkLater();
        }
        // Enter the event dispatcher.
        instance.enterEventDispatcher();
    }
   
    //Invoked when the user is putting the device into a power off state.
    public void powerOff()
    { }

    //Invoked when the device has left the power off state.
    public void powerUp()
    {
      Application.getApplication().removeSystemListener(this);
      doStartupWork();
    }

    //Invoked when the internal battery voltage falls below a critical level.
    public void batteryLow()
    { }

    //Invoked when the internal battery voltage has returned to normal.
    public void batteryGood()
    { }

    //Invoked when the internal battery state has changed.
    public void batteryStatusChange(int status)
    { }
   
    private void doStartupWork()
    {
      // Perform your start up activities here!
      Application.getApplication().invokeLater( new Runnable() {
        public void run() {
          Dialog.ask(Dialog.D_YES_NO, "Display?");
        }
      } );
    }
   
    private void doStartupWorkLater()
    {
      Application.getApplication().invokeLater( new Runnable() {
        public void run() {
          doStartupWork();
        }
      } );
    }
       
    public GVIntercepter()
    {    }
}

I'm using JDE 4.2.1.

Any ideas?


All times are GMT -5. The time now is 11:45 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.