Use of automatic start and RuntimeStore for UIApplication... Help!

I have a UIApplication that runs in the background and uses another entry point. The problem I have is to initialize the high device. The application will be auto-start and being thrust into the RuntimeStore (it seems anyway), and it will run in the background once the device boots-to top. But when I launch the first time through the graphical interface, trying to retrieve the existing instance of the RuntimeStore, he just return null. Thus, it instantiates the app again and place it in the RuntimeStore again, and then this will work as expected. Why the RuntimeStore put or get does not work the first time when the application auto-start? Any ideas?

Here's the code for my main application UI, which instantiaties just my screen class:

public class MyApp extends net.rim.device.api.ui.UiApplication
{
    private static final long APP_ID = 0xf46f5a7867d69ff0L;

    public static void main(String[] args)
    {
        RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();
        if (args != null && args.length > 0 && args[0].equals("gui"))
        {
            MyApp myApp = (MyApp)runtimeStore.get(APP_ID);
            if (myApp != null)
            {
                myApp.requestForeground();
            }
            else
            {
                runtimeStore.put(APP_ID, new MyApp(true));
            }
        }
        else
        {
            synchronized(runtimeStore)
            {
                runtimeStore.put(APP_ID, new MyApp(false));
            }
        }
    }

    public MyApp(boolean isGui)
    {
        this.pushScreen(new MyAppScreen(isGui));
        this.enterEventDispatcher();
    }
}

I think your problem might be because

enterEventDispatcher();

never actually "return", then the set RuntimeStore does not end.

Try the following code that does what you want.  I put some System.out.println statements for you can follow what is happening.  Place a breakpoint on the line after either of the enterEventDispatcher() to see if it's really there.

public class MyApp extends net.rim.device.api.ui.UiApplication {
   private static final long APP_ID = 0xf46f5a7867d69ff0L;

   public static void main(String[] args) {
      RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();
      MyApp _myApp;
      if (args != null && args.length > 0 && args[0].equals("gui" ) ) {
          _myApp = (MyApp)runtimeStore.get(APP_ID);
          if (_myApp != null) {
              System.out.println("Forground" );
              _myApp.requestForeground();
          } else {
              System.out.println("Create" );
              _myApp = new MyApp(true);
              runtimeStore.put(APP_ID, _myApp);              _myApp.enterEventDispatcher();
              System.out.println("dispatched" );
          }
      } else {
          System.out.println("Auto Start" );
          _myApp = new MyApp(false);
          synchronized(runtimeStore) {
              runtimeStore.put(APP_ID, _myApp);
          }
          System.out.println("Added" );
         _myApp.enterEventDispatcher();
          System.out.println("dispatched" );
      }
   }

   public MyApp(boolean isGui) {
       this.pushScreen(new MyAppScreen(isGui));
   }
}

Tags: BlackBerry Developers

Similar Questions

  • Determine the range start and stop for a partition partition

    Hello

    Using oracle 11.2.0.3

    We use the interval of separation and the partition Lems auto-generated variety. intervbal (range-hash) 1 month

    So what can you manually check the table and see Beach start and end of the partition is it possible to request to see data dictionary
    the range satrt and stop wishing to have script to automatically rename the generated system partitions based on the involved for example range if the generated partition has max date value

    waoul 3062013 want PART_201306

    Thank you

    >
    Checked user_tab_partitions as have sql geneerator can get the names of partition, but does not see the partition a dstop ranges.
    >
    Range of scores have NO ranges 'start and stop '. They have a high value and identification of the position.

    Data with partition key values< the="" high="" value="" and="" greater="" than="" or="" equal="" to="" the="" 'high="" value'="" of="" the="" partition="" with="" the="" next="" lower="" 'position="" id'="" goes="" into="" that="">

    You have not yet described what you need 'start' and 'stop' for.

  • How can I set a certain web page automatically start and open when I connect Windows?

    How can I set a certain web page automatically start and open when I connect Windows?  My company as a "Home Page" that I would like it to appear when I connect Windows.

    Hello.

    Yes, you can do it. The only way to do this is to create a startup items.

    STEP 1- Make sure that the home page is set correctly

    Second STEP- Creating a startup items

    How to create a startup items:

    1. Right click on the shortcut of browser (Internet Explorer, Mozilla Firefox, Google Chrome), then click on copy.
    2. Open the start menu, click all programs.
    3. Right click on the startup folder, click Explore.
    4. Right-click on an empty area of the Windows Explorer, click Paste shortcut.

    STEP 3- Restart the computer to apply the changes and see the effect

    Response to see if it helps.

  • I have a LaserJet P1606dn - all of a sudden, I can't use the automatic on both sides print - Please help!

    I have a LaserJet P1606dn - all of a sudden, I can't use the automatic on both sides print - Please help!

    Hello

    Make sure that the automatic duplex printing option is selected:

    Enter the control panel > printers

    Right click on the printer icon, and then click Properties (printer properties for Windows7).

    Click the Device Configuration tab.

    Make sure that the option allow automatic duplex printing is checked.

    If there is no change, try to uncheck the print manual duplex option below, then check any change.

    The terms may be a little different because my OS is not in English.

    The front part / duplex must be placed at the bottom left part of the device Configuration dialog box.

    Please let me know of any changes,

    Shlomi

  • Very slow start and run for Dell Inspiron 6400 XP times

    "I have a problem with an Inspiron 6400 brought to ' horribly slow start and run time.  XP Pro 32 bit SP3 patched up to date.  Cleaned up a lot of "undesirable", as the partially uninstalled programs, cleaned the files temporary etc. with CCleaner, cleaned and optimized the registry afer all the cleaning has been done, defragmented, tried to start without any of the boot files, disabled all unnecessary services and uninstalled virus checking software, (but ran several anti-virus controls) etc. - no help.   Safe Start Mode is faster, but... not at all normal - 1 1/2 minutes of screen to logon instead of close to 3 minutes.  A lot of memory (2 GB), which rises to 600 to 700 MB runnng all the stuff I've tried.  Hard drive is 1/3 used out of 120 GB with a 2 GB swap file.

    One thing I'm still scratching my head over - beyond the horribly slow boot - is very slow access to files even though everything seems to work normally, but as molasses in January.  Looking at the performance of the Task Manager tab when I run a copy of a file (whether via a cmd window or with Windows Explorer), I see a near max processor would be and the other with a small business.  Even if the customer says he had been getting worse for some time, after checking and cleaning of all things 'normal', my next thought was perhaps a bad disk or disk controller driver, but chkdsk ran very well (although it took hours) even if I ' d I have already updated all drivers (and even the DVD firmware and BIOS) on the Dell web site.  Oh, and I ran Dell Diagnostics (from bootable CD) updates all with no errors found.  And access to the slow file even with symptoms had max-processor occur with a copy of the file on a USB key that seems to eliminiate the hard disk, the disk controller and the pilot.

    The other interesting part of the display for a file copy task manager is that the processes tab simply shows System Idle 97 to 99%, with a percentage of casual for other processes as Explorer while I see 1 max out procesor on the performance tab.  That the same copy on your desktop shows 3-4% of the CPU usage and who is with active antivirus software.  I'm almost ready to fall toward a Windows reinstall, but would like to find the real reason behind this problem of puzzle...

    It of almost as if he's using PIO instead of DMA disk access, but... don't know how/where to test this.

    Look at:
    and

    Solved!   Thanks for the links, especially to each other.  An old but still a goodie!

    For those who have enquring spirits (and anyone else who stumbles across this thread), the primary IDE controller has been set to PIO and locked it.  Who would have thought that Windows slowly reduced the transfer speed, whenever he saw 6 errors on an IDE device until it has been reduced to PIO and then he locked it?  But the procedures described in the link of winhlp.com showed how to solve the problem.

    There are actually several problems that led to the final symptoms.  According to KB817472, the Atapi.sys has been improved in XP SP2 only degrade the speed of transfer on 6 consecutive errors instead of 6 cumulative errors.  And even though everything I have (Microsoft update) was seen and showed that this area was to SP3, I found that the driver for the controller layer IDE was the SP2 version.  Someone ran sfc previously perhaps?

    Oh, and I know now that the Task Manager process tab does not time processor kernal, but the performance tab.  Good to know...

    Thanks again to all who have responded.  Starting at the time of connection-question now is 40 seconds.   You'll love Untra DMA mode 5.   There is still a lingering question in my mind, since I've had the same symptoms of slow copy of a file on a flash drive.  Perhaps a link in some way to the way that Windows treats a flashdrive as a "drive"...

  • I have problem watching video on youtube it will start and play for 10 sec and stop

    When you try to watch a video on youtube or another network, it will start to play for about 10 to 45 sec and stop to let to memory buffer for hours custom go no where

    Click on the gear in the top right, symbol

    Point to security, and what is checked, uncheck the box
    Then click on internet options,
    Go to the Advanced section and check the box at the top of the page,
    Use rendering software instead of gpu rendering, apply and OK.
    Close and open a new window of ie9,
    Also make sure that your not using the 64-bit version of ie9, they are clearly identified and 64-bit operating system has two versions.
  • How to use a regular expression using the model concept and match for this scenario?

    Hi guys,.

    I have a string "we have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle.

    I need to replace the numbers based on the condition below.

    If more then 5, replace with many

    If less than 5 then replace by a few

    If it is 1, replace by "only one".

    Here is my code, I'm missing the part equates to replace the numbers could one of please help me solve you this.

    private static String REGEX = "(\\d+)"; "

    private public static String INPUT = "we have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle."

    String pattern = "(.*) (\\d+)(.*)";

    private static String REPLACE = "replace with many";

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

    Create a model object

    Model r = Pattern.compile ("REGEX");

    Now create object match.

    Matcher m = r.matcher (INPUT);

    Change the value to 7 by the replacement string

    How to assimilate (\\d+) greater than a number and use the code below.

    ENTRY = m.replaceAll (REPLACE);

    Print the final result;

    System.out.println (Input);

    Thank you and best regards,

    Hello

    Try the following makes use of 'appendReplacement"instead with the methods 'start' and 'end' to locate and check the search string"regExp"before dynamically set the string"replace ":

    String regExp = "\\d+";
    String input = "We have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle";
    String replace;
    Pattern p = Pattern.compile(regExp);
    // get a matcher object
    Matcher m = p.matcher(input);
    StringBuffer sb = new StringBuffer();
    while (m.find()) {
       Integer x = Integer.valueOf(input.substring(m.start(), m.end()));
       replace = (x >= 5) ? "many" : (x == 1) ? "only one" : "few";
       m.appendReplacement(sb, replace);
    }
    m.appendTail(sb);
    System.out.println(sb.toString());
    

    HTH.

    Kind regards
    Rajen

    PS: Please mark as answer/useful if it solves your problem to the benefit of all members of the community.

  • Re: NB200 - automatic plug-and-play for Ethernet cable

    Do you know why I don't have automatic plug-and-play, when I connect to internet ethernet cable on my NB200?

    Hey mate,

    Automatic configuration tell you exactly?

    Normally, nothing is plug-and-play. If you want an Internet connection via Ethernet cable, you must configure this port. This means you need to set a static IP or DHCP.

  • When I put a cd in the drive it will not automatically start and if I type in what he tells me sub run an always pop error and I can't to start

    Whent to repair it for me and it did not help

    Please click on the link below and follow the steps on the page:

    http://www.WikiHow.com/configure-CD-and-DVD-AutoPlay-in-Windows-XP

    MD MOEEN AJAZ KHAN - MCP, N +, A +.

  • I lost the ability to use the hue, Saturation and Luminance for a reason any? I now have the Calibration of the camera, which I never use. How can I get HSL back to develop the module?

    I've lost the ability to use the hue, Saturation and Luminance option in develop module. I now have the Calibration of the camera, which I never use. How to bring back HSL? Help!

    Use the menu command

    Window-> panels-> STL/color/black & white

  • Hi all, I'm Mike. I'm a newbie here and hoping for more help with my Aspire 5735

    Hi, as above, I bought the Aspire 5735 several years now. It is running Vista Home Premium SP2 and became excruciatingly slow. When first started it becomes unusable for a while during which it seems to be the continuous disk activity. I tried to look in the Task Manager to see what is happening, but that itself takes an age to start and then not show anything unusual. I also tried all the usual stuff such as disk cleanup, defragmentation and even had use CCleaner and clearing out the prefetch folder, but nothing helped.

    I finally decided that the only option is to use two recovery disks that I created when it was new in an attempt to restore it to factory State but I can't find information on the way to recovery. If anyone can help with this, I would be very grateful.

    Hello

    Look at this french video (only photos ).

  • While blue screens as windows starts and looking for help!

    Hello world

    I'm a big computer noob and I don't know much about it that's why I will ask my questions here, to get help from people who do not know how to solve this problem. So please try to explain it very easily so I can understand you.

    Let's head on the problem; Sometimes my computer completely random stops and restarts immediately after that it stops. It is not a normal shutdown, but it's as if I pressed the button stop or restart button, it stops immediately. To this problem in the past, but well, months when I started my PC upward once again, everything was going well, then I thought it was OK to use my PC with that bit of inconvenience. But yesterday my PC did the same thing but when I clicked on "Start windows normally" it appeared a blue screen which lasts only 0.5 seconds and disappears after it restarts my computer again. Then when I tried to start windows with recoveryoptions it gives me, after windows files have been loaded, another blue screen that doesn't go away until I have shut myself. I tried to boot my PC with a windows CD, but when I did it wat windows departure after loading files and then showed a blue screen.

    Information:

    -Windows 7

    -Asrock H61M-GS is the first thing with a menu of options when I start my PC.

    ------------------------------------------------------------------------------------------------

    A picture is to make it more clear

     <-- first="" i="" see="" when="" starting="">

    It is one of the blue screens, I was yesterday. But he continues to change when I do something different. Thus, the blue screens are not the same and error codes keep starting with 0x000000 but the last 2 digits change sometimes.

    I really hope that someone can help me... And if you're Dutch like me you can answer in Dutch... Would be easier for me to understand :D

    Sincerely,

    Etienne KT

    Problem solved. Taken from the video card of the computer and back in and it worked.

  • after upgrade firefow does not start and reinstall does not help

    Last week updated firefox and I can't use it since safe mode does not work, will not work reinstall I get a memory error code, pls help

    Submit incident reports at Firefox?

    If you have submitted reports of incidents, then thanks post IDS of one or more reports of incidents that have this format:

    • BP-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

    You can find the ID of the submitted crash reports on the Subject: hangs page.

    • You can open the Subject: hangs page through the address bar, you open a Web site.

    See:

    If you cannot open Firefox, see:

  • I checked all partion in my email, but it is not getting any email on change for my appleID security issue... difficulty my resloving .please I need to change my secret question and thanks for the help...

    I mean I'll change the security question in my applied in applied management it is sent to my email, but in the email, it is not getting this information to change the security question why?  Please

    Unless it is in a spam filter, you have to ask Apple to reset your security questions. To do this, click here and choose a method; If this page does not list one for your country or if you are unable to call, complete and submit this form.


    (137004)

  • Automatic start/stop for guest settings keep reproduce every time I access the properties

    Greetings,

    I have a single ESXi host 5.5 with a single Win 2012 std server prompt.   I have a second guest, but is not in production. Several months ago I "thought" I activated the auto start and stop for this particular customer.  Due to problems of food in the building today, I had the opportunity to stop the comments and the turning off of the host completely.   After the reboot of the host, my guest, never started (automatically). I connected to the host via vsphere client and started manually.  No problems.

    I decided to check the settings of automatic start/stop and it is set to manual.  So, either I never actually put it on automatic (and I just have problems of memory in my head (not unusual for me)) or I put it really, and something happened where he became disabled or brought back to the default value.

    That said, I went to properties of start-up automatic and as mentioned above, found it turned off, I was able to allow him, but when he returned to the screen (after clicking OK), it displays TWO of each of my virtual machines in the Autorun screen.  I went back to see if I could change/delete/remove the extras (I've found a way to do it), and when I came back out of the screen there are THREE virtual computers listed in the pane. See attachment.  Anyone know what is happening here and how can I remedy the situation?

    Am I just being a fool and lack of obvious?

    Thank you.

    P....

    Autostart.jpg

    Exit the VSphere client and restart it solved the problem.  I presume a video type of bug, or maybe a bug with my version of the client.

Maybe you are looking for