我是Tizen的新手,我尝试开发一个可穿戴的原生应用程序(2.3.2),通过单击按钮可以创建通知。到目前为止它的确有效,但我想知道通知是否可以自定义。
notification_set_time(notification, time(NULL));
修改,但它对我不起作用。只显示完全随机的值(不是实际系统时间;与代码行9中的notification_set_time_to_text
相同)。显示的通知中没有任何变化。当我尝试使用notification_set_time(notification, DO_NOT_SHOW_TIMESTAMP)
删除时间戳时,它会出错( DO_NOT_SHOW_TIMESTAMP
未知)。下面是代码的一部分,它涵盖了创建通知并设置其内容的整个功能。在第20行(标记为注释)中,我尝试添加一个带notification_set_button
的按钮,但这会导致错误。
void set_notification(appdata_s *ad){
notification_h notification = NULL;
notification = notification_create(NOTIFICATION_TYPE_NOTI);
if(notification != NULL){
notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE,
"Alarm",
NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
notification_set_time_to_text(notification, time(NULL),
NOTIFICATION_TEXT_TYPE_CONTENT);
notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT,
"Failure
of Valve 4",
NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
notification_set_display_applist(notification,
NOTIFICATION_DISPLAY_APP_ALL);
notification_set_size(notification, 0.5);
notification_set_layout(notification, NOTIFICATION_LY_ONGOING_EVENT );
//notification_add_button(notification,NOTIFICATION_BUTTON_1);
notification_set_vibration(notification,
NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
}
app_control_h app_control = NULL;
int noti_err = NOTIFICATION_ERROR_NONE;
app_control_create(&app_control);
app_control_set_app_id(app_control, "org.tizen.noti_basicui2");
noti_err = notification_set_launch_option(notification,
NOTIFICATION_LAUNCH_OPTION_APP_CONTROL,
(void *) app_control);
if (noti_err != NOTIFICATION_ERROR_NONE) {
notification_free(notification);
return;
}
app_control_destroy(app_control);
notification_post(notification);
}