Languages

Menu
Sites
Language
Does the Event-API work with native hybird apps (ui + service)?

Hi everyone, I'm trying to implement a package consisting of two native applications for wearables. The problem I face is that if I start both applications separately, the event-api works as it is supposed to work. But as soon as I combine both applications in one project via "Tizen Studio->Package->Multi" the Event-API doesn't work anymore. In the service I am no longer able to receive the events.

I prepared two code snippets and also got a minimal working example that I can send you if you want to test it yourself.

It consists of: UI-APP with the app-id org.example.uibuildersingleview. What it does: You push a button and execute the following code snippet

void view1_buSendSignal_onclicked(uib_view1_view_context *vc, Evas_Object *obj, void *event_info) {
    bundle *event_data = NULL;
	event_data = bundle_create();
	int ret = bundle_add_str(event_data, "new_config_key", "true");
	ret = event_publish_app_event("event.org.example.uibuildersingleview.newConfig", event_data);
	dlog_print(DLOG_ERROR, LOG_TAG, "ret value: [%d]", ret);
}

In the service I register the listener:

bool service_app_create(void *data)
{
    event_handler_h event_handler;
    int ret = event_add_event_handler("event.org.example.uibuildersingleview.newConfig", user_event_cb, "CUSTOM_EVENT_KEY", &event_handler);
    dlog_print(DLOG_ERROR, "UIB_APP", "service app create", ret);
    return true;
}

Do you have an idea what I'm doing wrong?

I also tested the "Message Port"-Api. Same behaviour! As soon as I combine the application in a project, the communication stops working.

I appreciate any help - I'm out of ideas...

Cheers Keaselstein

View Selected Answer

Responses

6 Replies
Paul L

Hi, does your service start?

Can you change 

"CUSTOM_EVENT_KEY"

to NULL and check results?

What is in 

user_event_cb

?

Please share you code with message port api.

Eckhardt

Paul, Thanks for your help.

 

I tried with "Null". Same result as before.

Here is the callback:

void user_event_cb(const char *event_name, bundle *event_data, void *user_data){
    dlog_print(DLOG_ERROR, "UIB_APP", "user event cb");

    return;
}

When I run the service and the ui-app separately, I'm able to see those logs from the user_event_cb.

As soon as I run it as a Multi-Project the user_event_cb isn't called anymore.

 

Here is the Port API code.

ui-app:

void view1_buSendSignal_onclicked(uib_view1_view_context *vc, Evas_Object *obj, void *event_info) {
        bool found;
        int ret = message_port_check_remote_port("org.example.service", "test", &found);
	if (ret != MESSAGE_PORT_ERROR_NONE)
	        dlog_print(DLOG_ERROR, "UIB_APP", "message_port_check_remote_port error: %d", ret);
	if(found){
		bundle *b = bundle_create();
		ret = message_port_send_message("org.example.service", "test", b);
		if (ret != MESSAGE_PORT_ERROR_NONE){
			dlog_print(DLOG_ERROR, "UIB_APP", "message_port_check_remote_port error: %d", ret);
		}else{
			dlog_print(DLOG_INFO, "UIB_APP", "Send message done");
		}
		bundle_free(b);
	}else{
		dlog_print(DLOG_INFO, "UIB_APP", "message port not found.");
	}
}

 

Service:

void user_event_cb(const char *event_name, bundle *event_data, void *user_data){
    dlog_print(DLOG_ERROR, "UIB_APP", "user event cb");

    return;
}

bool service_app_create(void *data){
        int port_id  = message_port_register_local_port("test", user_event_cb, NULL);
	if (port_id  < 0)
		dlog_print(DLOG_ERROR, "UIB_APP", "Port register error: %d", port_id );
	else
		dlog_print(DLOG_INFO, "UIB_APP", "port_id: %d", port_id);

       return true;
}

 

Mark as answer
Paul L
message_port_send_message

Do you start service from the uiapp using app_control_send_launch_request before using message port?

Eckhardt
Does the Event-API work with native hybird apps (ui + service)?

Hi everyone, I'm trying to implement a package consisting of two native applications for wearables. The problem I face is that if I start both applications separately, the event-api works as it is supposed to work. But as soon as I combine both applications in one project via "Tizen Studio->Package->Multi" the Event-API doesn't work anymore. In the service I am no longer able to receive the events.

I prepared two code snippets and also got a minimal working example that I can send you if you want to test it yourself.

It consists of: UI-APP with the app-id org.example.uibuildersingleview. What it does: You push a button and execute the following code snippet

void view1_buSendSignal_onclicked(uib_view1_view_context *vc, Evas_Object *obj, void *event_info) {
    bundle *event_data = NULL;
	event_data = bundle_create();
	int ret = bundle_add_str(event_data, "new_config_key", "true");
	ret = event_publish_app_event("event.org.example.uibuildersingleview.newConfig", event_data);
	dlog_print(DLOG_ERROR, LOG_TAG, "ret value: [%d]", ret);
}

In the service I register the listener:

bool service_app_create(void *data)
{
    event_handler_h event_handler;
    int ret = event_add_event_handler("event.org.example.uibuildersingleview.newConfig", user_event_cb, "CUSTOM_EVENT_KEY", &event_handler);
    dlog_print(DLOG_ERROR, "UIB_APP", "service app create", ret);
    return true;
}

Do you have an idea what I'm doing wrong?

I also tested the "Message Port"-Api. Same behaviour! As soon as I combine the application in a project, the communication stops working.

I appreciate any help - I'm out of ideas...

Cheers Keaselstein

Eckhardt

This solved it. Thank you. I added this snippet to the uiapp.

    app_control_h app_control;

	app_control_create(&app_control);
	app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
	app_control_set_app_id(app_control, "org.example.service");

	if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE)
	    dlog_print(DLOG_INFO, "UIB_APP", "Succeeded to launch a calculator app.");
	else
	    dlog_print(DLOG_ERROR, "UIB_APP", "Failed to launch a calculator app.");

Do you know if there are any exceptions that services start automatically when combined with uiapps? I'm asking because another service in my package is actually starting on its own. The only difference I see is that it used notification-API and SAP-API.

 

Anyways thanks again for you great help - you made my day!

(Something went wrong with my other reply, Hopefully someone can delete it.)

Paul L

Great:)

check this: https://docs.tizen.org/application/native/guides/app-management/event

Managing Launch-On-Events 

section