如何从本机 Web 应用程序制作的应用程序控件中获取应用程序控件的额外数据?

How to get app control extra data from app control which made by web application in native?

我想通过 app_control 在 Web 应用程序中启动带有数据的本机应用程序。 我在我的本机应用程序中找不到获取应用程序控制额外数据。 我已经尝试使用 'app_control_get_extra_data'、'app_control_foreach_extra_data'.

让我知道如何从 Web 应用程序的应用程序控件中获取额外数据。

在我的网络应用程序中,

    // Define the data structure describing application control details
    var appControl = new tizen.ApplicationControl(
                   "http://tizen.org/appcontrol/operation/default",
                   null,
                   null,
                   null,
                   [new tizen.ApplicationControlData("key",
                                                     ["data1", "data2"])] );

    // Launch an application with the specified application control
    tizen.application.launchAppControl(
            appControl,
            "net.msalt.myApplicationAppID",
            successCallback,
            errorCallback,
            appControlReplyCallback
        );

我建议您使用消息端口。 Tizen 为应用程序之间的数据通信提供消息端口。请检查..

Message Port Web Guide

Message Port Web API Ref

Message Port Native Guide

Message Port Native API Ref

检查Message port data Sending code from web app和Message port data Receiving code from native app。如果您给端口起一个通用名称,他们就可以通信,假设 "SAMPLE_PORT".

请注意,这两个应用程序应使用相同的作者证书签名。

我明白了! :)

如果 'data' 长度 == 1,使用 'app_control_get_extra_data()'

    // In Web Application
    // Define the data structure describing application control details
    var appControl = new tizen.ApplicationControl(
                   "http://tizen.org/appcontrol/operation/default",
                   null,
                   null,
                   null,
                   [new tizen.ApplicationControlData("key",
                                                     ["data1"])] );

    //In Native Application
    char *value = NULL;
    ret = app_control_get_extra_data(app_control, "key", &value);
    if (ret != APP_CONTROL_ERROR_NONE) {
        dlog_print(DLOG_ERROR, LOG_TAG, "Failed to app_control_get_extra_data(). Can't get extra data.");
    } else {
        dlog_print(DLOG_ERROR, LOG_TAG, "data [%s]", value);
    }

如果 'data' 长度 > 1,使用 'app_control_get_extra_data_array()'

    // In Web Application
    // Define the data structure describing application control details
    var appControl = new tizen.ApplicationControl(
                   "http://tizen.org/appcontrol/operation/default",
                   null,
                   null,
                   null,
                   [new tizen.ApplicationControlData("key",
                                                     ["data1", "data2"])] );

    //In Native Application
    char **array = NULL;
    ret = app_control_get_extra_data_array(app_control, "key", &array, &length);
    if (ret != APP_CONTROL_ERROR_NONE) {
        dlog_print(DLOG_ERROR, LOG_TAG, "Failed to app_control_get_extra_data_array(). Can't get extra data.");
    } else {
        dlog_print(DLOG_ERROR, LOG_TAG, "data [%s], [%s]", array[0], array[1]);
    }