Languages

Menu
Sites
Language
Tizen native service app to check if another web app is running

In Samsung gear S3, I want to develop a Tizen native service application which continuously checks if a web application is running or not and launches the web application if its not running. By continuously, I mean it can be either checking every minute or adding an event listener (for state change of application). I wanted to do this because my web application is getting terminated after some time (may be after a day or so) but I want it to run always in background. Right now,I was able to launch the web application from service application with the following code.

app_control_h app_control;
int ret = APP_CONTROL_ERROR_NONE;
ret = app_control_create(&app_control);

if (ret != APP_CONTROL_ERROR_NONE)
   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_create() is failed. err = %d", ret);

ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);

if (ret != APP_CONTROL_ERROR_NONE)
   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_set_operation() is failed. err = %d", ret);

app_control_set_app_id(app_control, "08CCMUEFHN.ROAMMprompt");

ret = app_control_send_launch_request(app_control, NULL, NULL);
if (ret != APP_CONTROL_ERROR_NONE)
   dlog_print(DLOG_ERROR, LOG_TAG, "app_control_send_launch_request() is failed. err = %d", ret);

I am new to the native app development in C. Kindly please help me in developing code to continuously check if my web application is running or not.

Regards,

Manoj.

Edited by: manojbattula on 16 Jun, 2017
View Selected Answer

Responses

4 Replies

I am able to check whether the application is running or not by getting its context using app_manager api.

For the timer,(to check every 1 min or so), I read about ecore_timer but it seems to be for UI native app and I dont get the way to use it.

Is there any other way of developing a timer on native service app? 

Any help would be appreciated. 

Regards,

Manoj.

Mark as answer
Armaan-Ul- Islam

Hello manojbattula, 

Instead of Developing additional Native Service application, Your Web application can itself Do your desired task. Tizen Alarm API enables you to schedule an application to be run at a specific time. When an alarm is triggered, the application is launched (unless it is already running). Register a repetitive alarm using Web Alarm API that would Launch the Web app itself after your desired time frame.

 

var appId = "com.samsung.clocksetting"; // Your desired appId, in this case 'settings' app

var alarmR = new tizen.AlarmRelative(2* tizen.alarm.PERIOD_MINUTE, 30 * tizen.alarm.PERIOD_MINUTE);

// Set an alarm in system that would trigger after 2 minutes and then every 30 minitues

tizen.alarm.add(alarmR, appId); 

 

Add 'alarm' privilege in your config.xml. Check out these Links for details implementation:

Tizen Web Alarm Guide

Tizen Web Alarm API References

Thank you so much. Its simple and brilliant.

I have one more question. My application is launched from a notification which pops up four times a day. Is there a way to know that the app is launched from notification but not by clicking on the app icon in the watch face.

Actually, I have to show one UI if app is launched from notification and another UI if app is launched by alarm(as you suggested) or launched by clicking on the app icon.

Armaan-Ul- Islam

My Suggestion Would be:

# When you launch your app using appId, Basically You are using an appControl. Now appControl can always be triggered with optional Data.

Instead of launching using 'app id' only,  Send extra data that would Identify from which segment the appControl is triggered. Such as "notification", "alarm api" ,etc.

You have to invest some time to look deep into resources.

https://developer.tizen.org/development/guides/web-application/application-management/application-information-and-controls/application-controls

https://developer.tizen.org/development/api-references/web-application?redirect=/dev-guide/latest/org.tizen.web.apireference/html/device_api/wearable/tizen/application.html#ApplicationControlData