Welcome!

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

Reply
New Developer
Posts: 5
Registered: ‎01-08-2010
My Device: Bold 9000
My Carrier: Rogers

AutoStart Application runs but can't get UI.

Hello,

 

We have recently build an application that runs in the background using autostart. I works fine until we decided to add an interface to it. Since the application is already running, the debuger Says: Starting myApp, myApp is already running!

 

Is there anyway to tell the main to bring the application in foreground if it is running instaed of trying to re-launch it?

 

Thanks,

 

Alex

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: AutoStart Application runs but can't get UI.

What you are doing works for me.  I have an auto-start UiApplication, that pushes a Screen, but does a requestBackground() to stay in the Background (actually to be honest, I'm not sure the requesBbackground() is needed).  Then the icon click just foregrounds it automatically.  You have to be careful that you do not let this Application exit, so rather than pop the last screen, on close you just requestBackground().  This does not use an Alternate Entry.  You will probably get people who will tell you to use Alternate Entry, you don't need to and it introduces complications with shared data.

 

The only trick with this is that your startup processing must what for a

ApplicationManager.getApplicationManager().inStartup() to be false

before doing any Ui related stuff.

 

Can I suggest you test out this approach by creating a new and very simple UiApplication with just one screen.  Create the start-up processing that waits for inStartup(), then pushes the screen and requestBackground().  Define an icon for it.  Then start up the SImulator.  On the Task Switch screen, you should see your application.  Switching to it, or clicking on your icon should bring up your Screen.

Developer
Posts: 131
Registered: ‎08-13-2008
My Device: Not Specified

Re: AutoStart Application runs but can't get UI.

Peter, I can't stress how important your message is. I've just changed the way my application works and I'm amazed - no more states inconsistencies in the GUI!

 

Using the alternative entry approach:

 

1) the GUI can be started at any point of the entire lifetime meaning you'll have to store everything you might need in the GUI, and load everything with accuracy.

 

2) Extremely difficult for users to completely exit your application and restart it manually, because your application is spread across 2 processes, one being an autostart system module (different entry point from Application icon).

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: AutoStart Application runs but can't get UI.

Glad that works for you. 

 

Can you mark this as solved?