Bada tutorial: Application basics

Now as we know how to create a project and already met the containers, we can start writing our application right away. And for this we will need to have a little concept about some basics of starting up an application. So today's post is on some elementary stuffs. May seem little bit boring but yet required!! 

I will not repeat the words already said in bada API doc. I put the links of API doc with each description. Please read the doc and find some additional concerns in this post.

First lets look at the following state diagram of an application. 


Fig: Application life cycle. Collected from bada API doc.


You probably already have seen this earlier. To start with an application we need to know exactly how to handle all the methods indicated in the diagram. Lets start with the first one...

OnAppInitializing: At the time of launching your application the system will call OnAppInitializing method to initialize it. Take a look at the bada API doc for this method. Notice that an AppRegistry& object is being passed as parameter which is usually used to restore your application to some previous state. This is the registry object for the application. You can save your application status in it and restore your application in OnAppInitializing method. Remember!! It is not an alternative of database. Keep as few as possible values in it.
This method is the very first method to be called. So initialize or allocate all necessary resources that you need to show your first screen. Your application may have different sequences, but whatever it is, the starting of that sequence should be here. Note that, this method is called only once in the application life cycle.

OnForeground: First, lets see what the bada API doc tells about it. From the API doc, you will be able to understand that this method can be called several times in a single life cycle of your application ( See the above figure to identify the sequence). So apart from resuming your application process, which is instructed in API doc, if you draw any screen in this method, make sure you are drawing the right screen in terms of the application state. If you see the template of a Frame based application, you will find this method drawing on a canvas.

OnBackground: Again the bada API doc includes quite comprehensive description. You should efficiently do the releasing and consuming resources in all these methods.

OnAppTerminating: Like the OnAppInitializing method, this one is also a pure virtual method of Application class. So you are must to implement this one. bada API doc have the necessary concerns about using this method. Please give attention to the Remarks section on the API doc. You can terminate your application by either pressing the End key or programmatically by calling terminate method of application class. In both cases OnAppTerminating will be fired.

Above methods are the common ones that need to handle. Refer to the Osp::App::Application class for the all other required handlers. 

So we looked into different state handlers of an application. But for a complete application we also need Forms, Frame etc. Next post will be on Form.

Share your thoughts and stay tuned.

Comments

Post a Comment

Popular posts from this blog

Ajax form submission with tiny MCE editor

Highcharts for Agile development

Try the "try" method and get rescued