Published on 25th of October 2017
Application Lifecycle

In this lesson we will consider the structure of an application code, look at the basic and the additional application events on the example of template, which was created in the lesson 7.

Entry Point to a Native Tizen Application

As in any program written in C/C++ language, native Tizen application starts with the main() function.

nw_008_01_en

In this example, the first line initializes the appdata structure. Usually, it stores pointers to all important application objects, such as: windows or layouts. Further, the event handlers were initialized.

Callback Methods

Tizen UI application, throughout its lifecycle, can be in five different states: creating, resuming, suspending, terminating and managing. When the application moves from one state to another, the system invoke the callback methods:

app_create() is called when the application is created. Here you can make basis for the user interface of your application (create a window, set its size, load a layout, etc.), initialize the components of the application model. If the function returns true, the main thread of the application will starts.

app_terminate() is called when the application is uninstalled. In this function, when the main thread of the application has completed its work, it is necessary to monitor the release of allocated resources, if any.

app_pause() is called when the application window is completely invisible for a user.

app_resume() is called every time the application window is shown to a user.

app_control() is called when the application receives a launch request from another application.

System Events Handlers

Now let's move on to the system event handlers. The function ui_app_add_event_handler() registers handlers of the following system events:

APP_EVENT_LOW_MEMORY – not enough memory.

APP_EVENT_LOW_BATTERY – low battery.

APP_EVENT_LANGUAGE_CHANGED – the input language was changed on the device.

APP_EVENT_DEVICE_ORIENTATION_CHANGED- the orientation of the device screen was changed.

APP_EVENT_REGION_FORMAT_CHANGED - localization settings were changed.

Function ui_app_main() starts the main cycle of the application after app_create() finished its work. If app_create() returns false, the main thread does not start, instead immediately will be called app_terminate().

In the next lesson we will see Tizen basic modules.

Leave a Reply

Your email address will not be published. Required fields are marked *