We write the first application for Samsung Smart Watch and OS Tizen

Hello hubr!
A recent publication described the first impressions of smart watch Samsung Galaxy Watch , working under OS Tizen. The next step was to find out how to develop custom applications for this system, both on an emulator and on a real clock.
We write the first application for Samsung Smart Watch and OS Tizen  
The process as a whole turned out to be uncomplicated (especially when programming for more than one year), although it has its own subtleties. Who is interested in the continuation, details under the cut.
Carefully traffic, many screenshots. Tizen Studio , the version is selected depending on the operating system. At the time of publication, the current version is 2.? and we will use it.
After installation, the Package Manager is started, with which you need to install the required development packages. We choose 3.0 Wearable .
As you can see from the screenshot, version 4.0 is only available as Preview, but we will not use new features now, so 3.0 is enough. In addition, you need to go to the Extention SDK section, and choose there. Samsung Certificate Extention . This is important, because Without certificate management, downloading the application on the clock will be impossible. By default, this component is not selected, and it was spent at least half an hour to find out why an error of the wrong certificate was issued.

Step 2. Creating the project

We have already installed IDE and almost became real mobile programmers now we can create a new project. Start Tizen Studio and select File -> New Tizen Project . A window appears where you can select Template (a new project template) or Samples (predefined examples). Choose Template, and in the desired platform window select Wearable 3.0.
The next item suggests choosing what to write - native or web-application, C ++ or HTML5.
Of course, only hardcore, choose C ++. The next step is to select the type of application, which is quite a lot. Choose Basic UI .
Other items are not so interesting, you need to choose the name of the application, the icon, etc. I chose the simple name test? the icon was left by default. At the end, the wizard creates an application consisting of the file test1.c and a tizen-manifest.xml file that stores the main application settings.
By the way, the development environment itself is based on Eclipse, and looks something like this.
Now the application can be launched on the clock emulator. Select the Tools - Emulator Manager menu. A window appears where you can select and start the emulator.
When the emulator is running, run the application from Tizen Studio. It is unlikely that it will fall into the Top-10? but considering that we have not written any code, and so not bad:

Step 3. Let's parse the code

Let's see what Tizen Studio generated for us.
Structure appdata Keeps pointers to the main controls used in the program. The main function calls the system function ui_app_main, which is initialized by all the main callback functions of the program lifecycle (app_create, app_pause, app_terminate, etc.).
typedef struct appdata {
Evas_Object * win;
Evas_Object * conform;
Evas_Object * label;
} appdata_s;
static bool app_create (void * data) {
appdata_s * ad = data;
create_base_gui (ad);
return true;
static void app_pause (void * data) {
int main (int argc, char * argv[]) {
appdata_s ad = {?};
int ret = 0;
ui_app_lifecycle_callback_s event_callback = {?};
app_event_handler_h handlers[5]= {NULL,};
event_callback.create = app_create;
event_callback.terminate = app_terminate;
event_callback.pause = app_pause;
event_callback.resume = app_resume;
event_callback.app_control = app_control;
ui_app_add_event_handler (& handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, & ad);
ui_app_add_event_handler (& handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, & ad);
ret = ui_app_main (argc, argv, & event_callback, & ad);
if (ret! = APP_ERROR_NONE) {
dlog_print (DLOG_ERROR, LOG_TAG, "app_main () is failed. err =% d", ret);
return ret;

More details about the life cycle of the program on Tizen can be read here .
Finally, we reach the function, where we create the required UI:
static void create_base_gui (appdata_s * ad) {
/* Window * /
/* Create and initialize elm_win.
elm_win is mandatory to manipulate window. * /
ad-> win = elm_win_util_standard_add (PACKAGE, PACKAGE);
elm_win_autodel_set (ad-> win, EINA_TRUE);
if (elm_win_wm_rotation_supported_get (ad-> win)) {
int rots[4]= {? 9? 18? 270};
elm_win_wm_rotation_available_rotations_set (ad-> win, (const int *) (& rots), 4);
/* Conformant * /
/* Create and initialize elm_conformant.
elm_conformant is mandatory for base gui to have proper size
when indicator or virtual keypad is visible. * /
ad-> conform = elm_conformant_add (ad-> win);
elm_win_indicator_mode_set (ad-> win, ELM_WIN_INDICATOR_SHOW);
elm_win_indicator_opacity_set (ad-> win, ELM_WIN_INDICATOR_OPAQUE);
evas_object_size_hint_weight_set (ad-> conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add (ad-> win, ad-> conform);
evas_object_show (ad-> conform);
/* Label * /
/* Create an actual view of the base gui.
Modify this part to change the view. * /
ad-> label = elm_label_add (ad-> conform);
elm_object_text_set (ad-> label, " is created inside the window. Conformant , which controls the creation of content of variable size (the size can vary, for example, when the keyboard is extended). In our application, it would be possible to do without it, too. We do not use the keyboard, but if there is, let it be. Finally, the last step is to create the object label . Pointers to all objects are stored in the appdata structure, which we discussed above. Finally, the last function evas_object_show shows the created window on the clock screen.
This could be finished, but it's interesting to write something of your own. We will bring up a button on the screen, at the touch of which the text label will change.
The elm_object_content_set function used in the example prints only one control. But we need to add a few, so use the component. Box , which in turn will be inserted into the container Naviframe .
We remove the creation of the Label from the above code and replace it with the code:
ad-> nf = elm_naviframe_add (ad-> conform);
evas_object_show (ad-> nf);
elm_naviframe_prev_btn_auto_pushed_set (ad-> nf, EINA_TRUE);
elm_object_content_set (ad-> conform, ad-> nf);
ad-> box = elm_box_add (ad-> nf);
evas_object_show (ad-> box);
elm_naviframe_item_push (ad-> nf, "My app", NULL, NULL, ad-> box, NULL);
ad-> label = elm_label_add (ad-> box);
elm_object_text_set (ad-> label, " https://developer.tizen.org/ko/development/guides interested persons can study it in more detail.
It is also interesting that in addition to the clock there are other devices with OS Tizen, for example, TVs.
I wish all successful people successful experiments.
+ 0 -

Add comment