03-18-2011 04:28 PM
Is there any documentation about the screen and uiapplications lifecycle? I only found something about the uiapplications:
Is there anything more complete? Like the android documentation:
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.
03-18-2011 07:36 PM
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.
12-02-2012 11:29 AM
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:
Let me know if this helps.
12-02-2012 12:18 PM
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.
12-02-2012 03:06 PM - edited 12-02-2012 03:06 PM
Thanks for the feedback! Really useful, i've just updated the diagram. Any other suggestions?