Search code examples
tizentizen-wearable-sdk

Tizen code to control the samung gear s3 watch buttons


I am trying to write a tizen program which has to do the following

  • When I do long press of any watch button then it has to call the specific emergency number

I do not find any sample code anywhere .. Did anyone already tried something like this?


Solution

  • In Tizen native you can implement this by following the process below:

    1. At first register a smartcallback to the button using the following line of code:

    evas_object_smart_callback_add(ad->button, "clicked", _btn_clicked, ad);

    1. After that write the _btn_clicked callback as below:

    static void _btn_clicked(void *user_data, Evas_Object *obj, void *event_info)
    {
       app_control_h app_control = NULL;
       app_control_create(&app_control);
       app_control_set_app_id(app_control, "com.samsung.call");
       app_control_add_extra_data(app_control, "number", THE_NUMBER_YOU_WANT_TO_CALL);
       app_control_add_extra_data(app_control, "launch-type", "MO");
       if(app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE)
       {
         dlog_print(DLOG_INFO, "test", "error");
       }
    
       app_control_destroy(app_control);
      
    }

    NOTE: Don't forget to add the lines below in the manifest file:

    <privilege>http://tizen.org/privilege/call</privilege>
    <privilege>http://tizen.org/privilege/appmanager.launch</privilege>

    I've shown the implementation for simple click event. You can implement the call action for a long press event in a similar way. For the implementation of long press event follow this link.