Tizen 本机服务应用程序检查另一个应用程序是否 运行
Tizen native service app to check if another app is running
在 Samsung gear S3 中,我想开发一个 Tizen 本机服务应用程序,它会不断检查 Web 应用程序是否 运行ning,如果不是 运行ning 则启动 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);
请帮助我开发代码以持续检查我的 Web 应用程序是否 运行ning。
无需开发额外的本地服务应用程序,您的 Web 应用程序本身就可以完成您想要的任务。
Tizen Alarm API 使您能够安排应用程序在特定时间 运行。触发警报时,将启动应用程序(除非已经 运行ning)。
使用 Web Alarm 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中添加'alarm'权限。查看这些链接以获取详细实施信息:
在 Samsung gear S3 中,我想开发一个 Tizen 本机服务应用程序,它会不断检查 Web 应用程序是否 运行ning,如果不是 运行ning 则启动 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);
请帮助我开发代码以持续检查我的 Web 应用程序是否 运行ning。
无需开发额外的本地服务应用程序,您的 Web 应用程序本身就可以完成您想要的任务。
Tizen Alarm API 使您能够安排应用程序在特定时间 运行。触发警报时,将启动应用程序(除非已经 运行ning)。
使用 Web Alarm 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中添加'alarm'权限。查看这些链接以获取详细实施信息: