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 Contributor
Execc
Posts: 3
Registered: ‎10-14-2013
My Device: 9700

Showing application in switcher (Alt+Esc) after it was backgrounded

Hi!

 

I've run into a following problem: I have an application, which starts in background mode (requestingBackground after start), and contributes a few buttons into a system menu. 

 

When user start an app from menu, it shows globalScreen (popup), which displays basically an upload indicator. 

Uploading can take quite a bit of time, so user is allowed to minimize an application (which pops the global screen).

 

The question is - how to make an application to appear in switcher again? 

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

Re: Showing application in switcher (Alt+Esc) after it was backgrounded

I am confused as to which application you are talking about here.  So here is some theory and you can tell us a little more about what is going on to help us give you a proper answer. 

 

Icons are attached to applications, and are displayed in the task switcher if the user is allowed to bring that UiApplication to the foreground (an application that extends Application has indicated it has no Ui involvement so will not have an icon in the Task switcher by default).  That decision is made by the method in the UiApplication called acceptsForeground.

 

I believe there is some additional control in OS 7 applications but I haven't looked at it.

 

So if you are running an Application (not a UiApplication) then the only on screen presence it can have is via a Global Screen.  The Global Screen is not attached to the Application.

 

Now can you explain exactly what sort of process (Application) is being started by the System menu.  I presume this is a separate application to the one that adds the menus or at least a separate application instance (has different start up parameters for example). 

New Contributor
Execc
Posts: 3
Registered: ‎10-14-2013
My Device: 9700

Re: Showing application in switcher (Alt+Esc) after it was backgrounded

Thank you for you quick answer!

 

A little more detail at what i'm trying to achive:

 

When an applications starts, it can be seen in application switcher (Alt + Esc, or hole menu key). However, it's not desirable to always show it here, so i'm sending it to background with requestBackground() call on startup.

 

Next, at some point, user invokes some functionality which creates an upload screen with progress bar e.t.c.

User can hide that screen by popping it, but upload process continues. At this point, after popping, i want my application to be visible in switcher again, to be able to show uploading state. 

 

My application class extends UiApplication, and it's programmed against 5.0 API. 

Btw, upload process are handled by exactly the same application. Maybe it's my design mistake (first app for blackberry). I should try starting another app instance instead of showing global screen, for my upload, perhaps.

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

Re: Showing application in switcher (Alt+Esc) after it was backgrounded

requestBackground() does not remove the icon.  So if you had an icon in the task switcher, and you issued requestBackground(), the icon will still be visible.

 

I think the issue here is that in fact, you think your application is still running and it is not. 

 

You presumably add the system menus and then terminate your application at start up time. 

 

You are then initiating the download processing as part of the System menu interaction.  These interactions are NOT run as part of your application.  They are running your code, but running it under the control of the application that was displaying the icon.  So your application is still not running and so will not be visible.

 

To get your application processing when a system menu is used, you really have two choices:

 

a) Leave your application running after start up, and have the menu issue a Global Event to pass a message to your application.  Your application will pick up the global event and process it.  You will have one instance of your application running that will process all requests.

b) Have the system menu launch your application.  You can pass parameters to the launch that specify what the processing is to do.  Then your application can interrogate the passed in parameters and process from there.  Presumably the passed in parameters will be different for each different invocation, so you will a new instance of your application (and so a new icon in the task switcher) for each time your application is used.

 

I am not sure which of these two options suits your requirements.  I like (b).