How many classes in a project may extend UiApplication? Is there an incompatibility of piles of screen just in case both classes extend UiApplication (assuming it's allowed)?


As much as you want.  Main however will only be invoked when an Application descriptor is used for an Application that is NOT active, so you have only the option of "EnterEventDispatcher once by UiApplication.»  If you cannot display multiple batteries for a single UiApplication.  Note here that I speak not UiApplication as instantiated and used in the BlackBerry, no classes in your Application code.  .

Tags: BlackBerry Developers

Similar Questions

  • Passing an object of the UiApplication class reference

    Hi all

    I am very new to the development of BB and have struggled for hours on something that I think should be very simple. What I have, this is the main class that extends UiApplication and a second class that implements Runnable. From a method in the UiApplication class, I create an instance of the Runnable class. After that, I call a method to start from this class and pass an object originally from the UiApplication class reference - so that I can call a method, once completed the processing of the Runnable class.

    The problem I have, is that once past the object through a call to method reference, the reference instantly cancels and causes a NullPointer exception when trying to call a method in the original class. The structure is as below, but with all the surrounding code subscribed:

    public class MainApp extends UiApplication {
        MainApp _MainApp;
        OtherClass _OtherClass;
        public static void main(String[] args) {
        MainApp _MainApp = new MainApp();
        private void createOtherClass() {
            _OtherClass = new OtherClass();
        public void response() {
            // code here
    public class OtherClass implements Runnable {
        MainApp _MainApp;
        public void someMethod(MainApp MainAppRef) {
            _MainApp = MainAppRef;
            // _MainApp object reference is null here
            new Thread(this).run();
        public void run() {
            // stuff here
            // once done, call a different method
        public void sendDetailsBack() {
            _MainApp.response(); // causes a NullPointerException

    I rewrote this to only show the code at the source of the problem. I don't quite understand why the object reference is not passed correctly - I have tried many other ways to call back to the UiApplication function, including static calls.

    Any help on how I do it is very appreciated!

    Will be

    I suspect that your problem is here:

    MainApp _MainApp = new MainApp();

    I think you meant just

    _MainApp = new MainApp();

  • UiApplication using PopupScreen

    Hi all

    This is my first post on this amazing forum. I read through many large threads with lots of answers to the questions I had in my short time developing applications for the BlackBerry smartphone. Unfortunately, I hit my first stumbling block, which I'm sure will be very easy, but hey, we all start somewhere.

    The question that I'm doing the experience simply creates a PopupScreen in the mainevent thread and wait for user input before continuing. In my days of Swing I just use an observable model and notify the application of change, but I seem to have trouble with this concept here. I tried to use the pushModalScreen and the pushGlobalScreen of the UiApplication class methods, but both give me a runtime... error pushGlobalScreen called by thread of non-event.

    It seems to me missing something probably just in front of me, but I would appreciate help on this. I just use this example using the 9000 Simulator that is packed with the JDE v4.6

    public static void main(String[] args) {
            MyApp app = new MyApp();
        MyApp() {
            final PromptTest prompt = new PromptTest();
            invokeLater(new Runnable() {
                public void run() {
        public void continueProcess() {
        // do something with input from PopupScreen

    Thank you.

    Well, I'm a little bit embarrassed. I have solved my problem. Using just pushScreen, like any other approach and all simply migrate code to deal with in my fieldChangeListener. I don't know what I thought earlier. I'm sorry to have lost someone's time on this one.

  • Push the message overall form of a substantive uiapplication

    I have a uiapplication, which has a user interface with the main menu, mainscreens and other things, but it works also on startup, in order to keep listening for updates. I made a point of entry for it, so I can push the GUI when I want to.

    And I want to inform the user, with a simple dialog screen, when theres updates day and asks if he wants to start the application (gui).

    The problem is: I want the dialogue on the home screen, like a simple notice, but I couldn't, because I try pushGlobal the uiapplication on background, and even if I had the Ui.getUiEngine (), it returns the uiengine uiapplication and then it only shows if I enterEventDispatcher(), with a white background.

    I can't extend ask just to show the dialog boxes, because my application's gui.

    I think I may have need to create two applications, an Application that extend, to manage the listener in the background and to be able to pushglobal dialogues on the home screen and an another UiApplication which extend, can be described as the first.

    Is there another approach? Is it possible to dialog boxes of pushGlobal on the home screen of a uiapplication?

    I searched a lot but I have not found someone who wanted to do what I need. In fact I think I'm on the wrong track, so I hope someone will have the answer to my problem.

    So, as I thought, the solution is quite simple.

    I created another class that extends the Application and when I want to start the listener in the background, instead of instantiating my UiApplication I just instantiate this class, which looks like this:

    SerializableAttribute public class BackgroundListener extends Application {}

    Public Sub startBackgroundThread()
    New Thread() {}
    public void run() {}
    While (true) {}
    try {}
    Thread.Sleep (180000);
    } catch (InterruptedException e) {}
    e.printStackTrace ();

    do my logic

    synchronized (getEventLock()) {}

    with this UiEngine, I am able to pushGlobal dialog boxes

    When I want to with the application in the background

    UI UiEngine is Ui.getUiEngine ();.
    Screen = new dialog box (Dialog.D_OK, "You have updates!",
    Dialog.OK, Bitmap
    .getPredefinedBitmap (Bitmap.EXCLAMATION),
    ui.pushGlobalScreen (screen, 1, UiEngine.GLOBAL_QUEUE);
    }. start();

    And my main method ends like this:

    Public Shared Sub main (String [] args) {}

    {If (args.length > 0 & {args [0] .equals ("gui")})}
    MyUiApp app = new MyUiApp();
    app.showGui ();
    app.enterEventDispatcher ();
    } else {}
    BackgroundListener app = new BackgroundListener();
    app.startBackgroundThread ();
    app.enterEventDispatcher ();

    Thanks for listening! Laughing out loud

  • TimerTask calling UiApplication.getEventLock)

    I use a Timer object for several TimerTask objects that are run at various intervals (a few times per second, approximately every 30 seconds, etc, so nothing urgent). These objects TimerTask do very little work but they access various areas (e.g., setting the text of an EditField), and they call UiApplication.getEventLock () prior to do. And it works fine, no problem.

    However, in order to ensure I'm good things, because TimerTask or objects of a Timer object to follow very quickly, calling UiApplication.getEventLock () would be a problem, as it can effectively block thread of the Timer object, which is supposed to "finish quickly." Thank you

    The worst that will happen is that tasks planned for the future will be delayed in their execution. If your tasks are not urgent, then don't worry in this regard. In any case, nothing on the thread of the event is supposed to take long, either, so the wire from the timer should not have to wait a lot to synchronize the lock.

    If this is a concern, you can always use invokeLater rather than synchronize the lock of the event.

  • Occurrence of-> UncaughtException UiApplication

    Hi guys.

    I certify the source code.

    My application has a screen.

    The main point is to add several LabelFields to screen in thread.

    public class MyApplication extends MainScreen {
         public MyApplication() {           ..............     }
         public void addInfoField(LabelField info) {           this.add(info);     }
         private class AddInfoFields extends Thread {
               public void run() {
                      for(int i = 0; i < 150; i++) {                       ....                       final LabelField info  = new LabelField(".....");                       UiApplication.getUiApplication().invokeLater(new Runnable() {                            public void run() {                                  addInfoField();                            }                       }                  }           }     }}

    My question: is there presence rising UncaughtException (such as the queue is full) repeatedly for () ?

    Thank you guys.

    Yes, exactly. You're hungry the UI of event thread. Accordingly, is filled with the message queue and the OS kills your app and a trace of the stack of the forces.

    The form of the device stack trace and look at the object that caused the exception.

  • UiApplication - implementation RuntimeStore vs make Singleton object / Instance

    Hi all

    I ran into a lot of trouble with putting the UiApplication instance in the RuntimeStore for later retrieval of etc. other entry points.  I used the code of this resource (http://supportforums.blackberry.com/t5/Java-Development/Make-a-running-UI-application-go-to-the-back...)

    //register the alternate on first run
    RuntimeStore appReg = RuntimeStore.getRuntimeStore();
       if (appReg.get(ID) == null) {
           appReg.put(ID, new Application(...));
       Application MyApp = (Application)appReg.waitFor(ID);
       //then you have the app MyApp... return it or whatever
    //check to see if the app exists, if it does, bring it to the foreground ...RuntimeStore appReg = RuntimeStore.getRuntimeStore();synchronized(appReg){   if (appReg.get(ID) != null){       Application MyApp = (Application)appReg.waitFor(ID);       MyApp.requestForground();   }}

    but UiApplication.getUiApplicationInstance (); Returns IllegalStateException.

    I have posted this before and have read that I might be better to create a Singleton instance of my UiApplication - can I get some advice about how to achieve?  The code I think I should reference is:

    import net.rim.device.api.system.*;
    class MySingleton {
       private static MySingleton _instance;
       private static final long GUID = 0xab4dd61c5d004c18L;
       // constructor
       MySingleton() {}
       public static MySingleton getInstance() {
          if (_instance == null) {
             _instance = (MySingleton)RuntimeStore.getRuntimeStore().get(GUID);
          if (_instance == null) {
             MySingleton singleton = new MySingleton();
             RuntimeStore.getRuntimeStore().put(GUID, singleton);
             _instance = singleton;
          return _instance;

    Thanks in advance for any help.

    Sorry, I have not looked at your code in detail.  Simon and I wanted to understand what your application was trying to do, rather than how he did.

    What you have described so far, there is no need to put your UiApplication in RuntimeStore.  Or do you need an AlternateEntry.

    So let us try to see if we can get your app working the way you want without steps.  I'm not saying that we will succeed, but trying, we and you will understand better opportunities.

    But note that this is only my opinion and here's how I would implement what you're trying to do, with a single application. I could be missing something.

    Let's start with the listeners.

    Some listeners require a current request - for example SystemListener.  Some are not, for example telephone headsets.  Treatment is kept on a warm reboot - for example, most of the non networking Threads will be suspended and restarted.  Some are not, for example, the ApplicationMenuItems are deleted.

    Assume that at least one of your listeners requires an Application.  In general, I do not use an Application, because I use SystemListener so that I can terminate my treatment in extinction and restart under power.  Which means that you must have an Application that is started automatically.

    Now, you also want to have an icon.  Since an icon is supposed to start a UiApplication, then let us do your started automatically asks a UiApplication.  To do this, you really push a screen, but it can also "requestBackground()", so that it does not actually appear in the autostart.

    The complication here is that some of this treatment actually impossible in the early stages of implementation service, so you need to check for

    ApplicationManager... inStartUp)

    and treat them accordingly.  There is an article that describes what I think.

    So now we have one started automatically UiApplication, who listens to the system start and stop and everything stops at the stop and everything begins to start.

    Now, when you click the icon, you will not actually start your application, you're just before an existing UiApplication.

    I think that so far we have matching your needs with one exception.  What happens if you want to restart your Application?

    We have already described code that stops the processing of your request - we will work this in extinction.  You just need to run that and then do a system.exit().  Now, when your hand is called, the next time that the user clicks on the icon, it will be started just as if it was during the auto-start and will go through the same initialization.  The trick is this time, you don't want to do the requestBackground.

    Here is the key.

    (1) an initialization routine that adds the headphones and starts the other treatment.  This will also push the initial screen.

    (2) an interrupt routine that stops the treatment started in the initialization routine

    (3) main routine creates the UiApplication and adds it as a SystemListener and enterTheDisplatcher.  It checks to see if the treatment is inStartUp.

    (a) if so it horizons application - initialization will be done by the power of SystemListener.

    (b) otherwise, it executes the initialization routine

    (4) SystemListener powerUp routine that performs the initialization routine

    (5) powerOff routine SystemListener which runs the completion routine

    (6) output in your application that runs the completion routine and then call system.exit().

    I think that if you implement these parts, you will have a DBMS which deals with the way you want, with no RuntimeStorage and no AlternateEntry.

  • RecordStore opening to outside the UiApplication


    What is the right way to open the store from outside the UiApplication?

    I can't open the store like that? :

                   try {
                        recordStore = RecordStore.openRecordStore("data98989", true);
                   }catch (RecordStoreException rse) {
                       //exception handling

    I have already given on the RecordStore the UiApplication and want to read the data in the callDisconnected of the AbstractPhoneListener method. Can I do this? How do I do that?

    I've already implemented the AbstractPhoneListener and it works and listening to calls, but it just does not load data from the RecordStore. Can someone help me on this?

    Thanks in advance.

    A RecordStore can be opened only by the MIDlet Suite/Application that created it.  Note that the listeners on a BlackBerry can run in a different process to your application.  This may prevent access to a RecordStore leave in a listener.  As a work around you can use a BlackBerry persistent object.

  • How can I put a uiapplication and application in a project

    I'm a green hand and not good in English.

    I want that my blackberry project contains a uiapplication and an application which is a background thread, AutoStart, do not display the icon on the home screen.

    How to set my BlackBerry_App_Descriptor.xml?

    Please help me!

    Thank you!

    First and most important of all... Welcome to the BlackBerry forums

    Start reading this article.


  • Confusion on UiApplication and Application in a

    Dear all,

    My concepts on UiApplication and Application are clear, but I'm getting confused by looking at applications such as CallBlocker etc. as

    Here are the requirements of my application

    (1) have a background application that starts automatically at the startup of the phone upward and done something.

    (2) when a particular event occurs then, open the UiApplication where we allow the user to enter something

    If the above tasks are to be done, I am able to do it by two different applications and installing it. But what I want is to have a single packaged application do two things.

    CallBlocker applications are unique packaged applications that have associated UI work and not work on user interface.

    My questions are so

    (1) are two distributed applications together somehow? (this seems a very stupid question if I understand that an application can be Ui or without AC)

    (2) ins Anternate concept being used entry point is these cases?

    Indications in this sense?


    What are the documents you find missing?

    -l'API is documented so ok, if you know what you are doing you can work with it fine.

    -the developer guides are very detailed, it takes days to read them all. you have videos on top.

    -you get dozens of examples of applications that cover almost everything you want to do in the first half - just avoid copy & paste and try to include some path.

    -knowledge base is large enough. some articles are old, but you will find something for many topics, like the two I linked.

    -the forums contain an overview on problems, just use the search

    (click on the link on resources)

    There are weak points on the development of bb, but I don't think they are related to the documentation.

  • UiApplication.getEventLock () while alread in case of discussion?

    Hi people,

    I have a busy indicator, which is sometimes called from threads of the event and sometimes by background threads.

    Question: Although the extreme example below seems to work, does anyone know of an official RIM statement on the call of the lock of the event from somewhere that happens so that the event thread (as when a user presses a button)?

    Extreme example to get the lock event while in the wire of the event

    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
    public void run() {}
    {Synchronized (UiApplication.getEventLock ())}




    Thank you

    I think that it is harmless to synchronize the lock of the event when already on the thread of the event. However, you can always check by using Application.isEventDispatchThread () (or Application.isEventThread (), if you have a ref for instance practice).

  • make null pointer exception when accessing a persistent in UIApplication storage

    Hi, I do an apps which depends on a persistent storage, it checks the value, if the screens of its 'regtrue', load screen1 otherwise. I'm getting to chain data.getMessage () null pointer exception

    public class uiApp extends UiApplication {}
    Public Shared Sub main (String [] args) {}
    Data StorePersistent = new StorePersistent();
    PAP uiApp = new uiApp();
    theApp.enterEventDispatcher ();
    public uiApp()
    {StorePersistent data = new StorePersistent();
    String gotMsg ="";
    PersistentObject store = PersistentStore.getPersistentObject (0x946aa64a17ee9165L);
    synchronized (store) {}
    data = new StorePersistent();
    data = (StorePersistent) store.getContents ();
    if(Data == null) {}
    data = new StorePersistent();
    Store.Commit ();
    gotMsg = data .getMessage ();
    If (gotMsg.equalsIgnoreCase ("Regtrue"))<------------------------NULL>
    pushScreen (new login()));

    on the other

    pushScreen (new MenuScreen2());

    SRY, it was a stupid mistake, I was retrieving information that was never stored

  • can uiapplication two in one application, or on request and a uiapplication

    examplenot class extends the Application, again a Uiapplication when I heard something happens, I can do?

    I try, but hava a runtimeexception (104), can someone help me?

    I think it would be better that you could clarify what you are trying to reach, instead of indicating the technical path you think you can do.

    In general however, I believe you can use ApplicationManager to launch a new UiApplication from any code, including a "listener" Application, if that's what you try to do.

  • I need to extend the GameCanvas but also UiApplication

    Hello. I'm working on a game for the BB and I have a problem. The game is designed to work on other mobile devices, while it extends the common classes of MIDlet and GameCanvas. Now I'm trying to transfer my application on BlackBerry, and I'll try to find a way to extend the UiApplication and screen, classes because I need to register for keyListeners, trackBallListeners, override the navigationMovement (...) method, etc. I'm sorry if I ask too much or what I want can't happen, but I am new to J2ME and RIM. Thank you!

    game of public class extends GameCanvas implements Runnable {...}
    public class MIDlet extends MIDlet {...}

    you need to switch to the UI of the rim infrastructure, then. one or the other.

  • Question about UiApplication.getUiapplicatin ().

    Hi all,.

    Hope everything goes well. In fact, I want to ask UiApplication.getUiApplication () gives you your application instance (please, correct me if I'm wrong). Let's look at the code

    public class SimpleSmsChatApp extends UiApplication  {
        // Constructor
        public SimpleSmsChatApp() {   
            //Create the main screen and push it on to the display stack
            SimpleSmsChatMainScreen mainScreen = new SimpleSmsChatMainScreen(chatScreen,  createProfileScreen);
        } //end of constructor
        public static void main(String[] args) {
            //Create an instance of the application
            SimpleSmsChatApp app = new SimpleSmsChatApp();
            // Start the event displatch thread
        } // end of main()
    } //end of class SimpleSmsChatApp

    It is a main class simple code. Now suppose I have add a method in this class as follows

    public class SimpleSmsChatApp extends UiApplication  {
        private CreateProfileScreen createProfileScreen;
        private ChatScreen chatScreen;
        // Constructor
        public SimpleSmsChatApp() {   
            //Create the main screen and push it on to the display stack
            SimpleSmsChatMainScreen mainScreen = new SimpleSmsChatMainScreen(chatScreen, createProfileScreen);
        } //end of constructor
            public static void main(String[] args) {
            //Create an instance of the application
            SimpleSmsChatApp app = new SimpleSmsChatApp();
            // Start the event displatch thread
        } // end of main()
        public ChatScreen getChatScreen() {
            if (chatScreen == null) {
                chatScreen = new ChatScreen();
            return chatScreen;
        } //end of getChatScreen()
          public CreateProfileScreen getCreateProfileScreen() {
            if (createProfileScreen == null) {
                createProfileScreen = new CreateProfileScreen();
            return createProfileScreen;
        } //end of getChatScreen()
    } //end of class SimpleSmsChatApp

    Now I have another class in which I have pimples. Suppose that on the button clicks I want to createProfileScreen and window shows. I have code like this

     if (field == searchButton) {
         CreateProfileScreen createProfileScreen = UiApplication.getUiApplication().getCreateProfileScreen();                                                                                             UiApplication.getUiApplication().pushScreen(createProfileScreen);
     if (field == chatButton) {
         ChatScreen chatScreen = UiApplication.getUiApplication().getChatScreen(); 

    My question is that


    gives you the instance of the same instance I created in my main class i.e. SimpleSmsChatApp. But it gives me the error that cannot find symbol getChatScreen().

    I want to ask that whe


    give me the instance of the main class (SimpleSmsChatApp) and I have getChatScreen() and getCreateProfileScreen() in my main class so why it gives me error that cannot find symbol.

    I'm doing this because I want any number of screens I have in my project, I created each instance of the form only once and then call the instance whenever I need fron any class.

    Please clear my confusion about UiApplication.getUiApplication (). No matter what I'm doing wrong and how achieve what I'm trying doesn't mean created instance only once and call it whenever I need any class

    Thank you

    UiApplication.getUiApplication retrieves the current instance of UiApplication.

    Please modify your code to convert, and then call the function like this:


Maybe you are looking for

  • Problems with Equium L350D - 11 d

    I just bought this laptop today. MI problem is now when I turn it on, 3 Web pages display on the screen, each of them is "Google End User License Agreement", and I can't get rid of the any of them. Each of them says cannot display the Web page and sa

  • With the help of a Butterworth filter without phase shift

    Hello I found this reference to the use of a Butterworth filter without phase shift http://zone.ni.com/devzone/cda/epd/p/id/2775 but I can't open the sample with LabView 2011.  Can anyone help?  The referenced file is attached. Is there another or th

  • Stop Facebook app

    Is there anyway to disable the facebook app? It's not a really big deal, but I'd rather just that it not be there. Before buying, I didn't create the facebook account has been necessary, I just ignore. All I really want to show is my email. There are

  • "WindowsUpdate_8024002D" "WindowsUpdate_dt000", MicrosoftWorks9

    Try to download and install an update from ms for works9 I asks me to put in the DVD or the CD with the original file from works9.msi on it.  I did not receive all the ms disc with my Dell laptop and the file does not appear on my hard drive.  I keep

  • Additional details for Explorer Windows and Extraction

    I customized the display to view information of media with file, such as the duration, bitrate etc.. How the dump in the text file? Could not find all the parameters with the Dir command to dump this special items. Thank you BhaktaVatsal