Tizen本机服务应用程序,以检查是否有其他应用程序正在运行

时间:2017-06-16 15:48:29

标签: service native tizen

在Samsung gear S3中,我想开发一个Tizen本机服务应用程序,该应用程序不断检查Web应用程序是否正在运行,如果Web应用程序未运行,则启动它。 通过不断地,我的意思是它可以是每分钟检查或添加事件监听器(用于状态更改应用程序)。

我想这样做是因为我的网络应用程序在一段时间后(可能在一天左右之后)被终止但我希望它总是在后台运行。

现在,我可以使用以下代码从服务应用程序启动Web应用程序。

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);

请帮我开发代码,以便不断检查我的网络应用程序是否正在运行。

1 个答案:

答案 0 :(得分:0)

您的Web应用程序本身可以执行您想要的任务,而不是开发其他本机服务应用程序。

Tizen 警报API 使您可以安排在特定时间运行应用程序。触发警报时,将启动应用程序(除非它已在运行)。

使用Web Alarm API注册重复警报,该警报API将在您想要的时间框架后启动Web应用程序。

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);

添加'闹钟' config.xml中的特权。有关详细信息,请查看这些链接:

Tizen Web Alarm Guide

Tizen Web Alarm API References

相关问题