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
felipelcoutinho
Posts: 3
Registered: ‎03-16-2011
My Device: Torch 9800
My Carrier: Developer

Screen and UiAplicattion lifecycle

Hello,

 

Is there any documentation about the screen and uiapplications lifecycle? I only found something about the uiapplications:

http://www.blackberry.com/developers/docs/5.0.0api/AppLifecycle-summary.html

Is there anything more complete? Like the android documentation:

http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

I'm developing an application that uses camera. I'm  worried about not dealing with some event, then this will cause problems when the application is running.

 

Thank you,

 

Felipe.

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: Screen and UiAplicattion lifecycle

Hi and welcome to BlackBerry.

 

The documentation you have seen for the BlackBerry is pretty much it.  Being honest, most programmers, especially at the start, treat the start-up code like a magic incantation - you just follow it and your screen gets opened when the icon is clicked.  You don't really have to understand it.

 

And you use System.exit() to close.  Sometimes this will be done automatically for you, for example, if you close the last screen in your Application. 

 

The rest inbetween is just Event Processing, i.e. responding to key presses and data entry. 

 

Screens are Objects like everything else, you just push them onto the display stack to display them, and pop them off when you don't want to display them any more (i.e. you close them).  The top screen on your Display Stack is the one your user will see - assuming your application is in the foreground. 

 

There are a lot more other things that you can do/use, like use onExposed in a screen to figure out when the screen is 'exposed', and activate and deactivate in your Application to determine when you are swapped to the background or back to foreground, but you can get a pretty good application going without worrying about any of these technicalities. 

 

I recommend that you take the CameraDemo, which works OK on the Simulator and step through, noting what goes on.  The trick with the Camera is to use the Player interface, but that is pretty well documented. 

 

Just a heads up, there is another trick with the invoking the camera directly within the Application.  Basically in my experience, it really doesn't work well on some devices.  Search the forum for more on this. 

Please use plain text.
New Contributor
zan_kavtaskin
Posts: 4
Registered: ‎12-02-2012
My Device: bold 9790
My Carrier: o2

Re: Screen and UiAplicattion lifecycle

When i started working with Blackberry i didn't find much information either.

This is why i ended up creating a simple flow chart to give an overview:

 

http://blog.appacts.com/post/2012/04/29/Blackberry-application-life-cycle.aspx

 

Let me know if this helps.

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: Screen and UiAplicattion lifecycle

Useful, but some inaccuracies I think.

1) The diagram suggests that Application main calls Application activate() and so which of course it does not.  Application main uses enterEventDispatcher() to start the Main Event Thread.  The Event Thread calls these methods, but they are distinct calls, and they return, which the diagram does not clearly show

2) onExposed is not called the first time a Screen is pushed and displayed, onDisplay(), now onUiEngineAttached(true) is called.  onExposed is called only after a Screen has been displayed

3) You have missed onUndisplay() (now onUiEngineAttached(false))

4) Application exits by calling System.exit().  MainScreen will call this automatically when you call close and there is only one screen on the stack. I suspect this is why you think that close is involved here.

5) I like the onObscured/onExposed loop - that is a good explanation

6) This description only applies to applications with UIs.

Hope this is helpful.

Please use plain text.
New Contributor
zan_kavtaskin
Posts: 4
Registered: ‎12-02-2012
My Device: bold 9790
My Carrier: o2

Re: Screen and UiAplicattion lifecycle

[ Edited ]

Thanks for the feedback! Really useful, i've just updated the diagram. Any other suggestions?

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: Screen and UiAplicattion lifecycle

Link doesn't seem to work any more?

Please use plain text.
New Contributor
zan_kavtaskin
Posts: 4
Registered: ‎12-02-2012
My Device: bold 9790
My Carrier: o2

Re: Screen and UiAplicattion lifecycle

Please use plain text.