【问题标题】:Tizen Native Service: Unable to Get LocationTizen 本地服务:无法获取位置
【发布时间】:2019-11-26 08:26:46
【问题描述】:

我正在尝试在我的 Gear S3 Frontier 手表上获取位置。启用定位服务后,我无法得到任何响应。

一些相关代码:

location_manager_h location_manager;                                            
location_service_state_e location_service_state = LOCATIONS_SERVICE_DISABLED;

void setup_location_manager()
{
    if (location_manager_create(LOCATIONS_METHOD_GPS, &location_manager) != LOCATIONS_ERROR_NONE)
    {
        dlog_print(DLOG_DEBUG, LOG_TAG, "setup_location_manager: Failed to setup the Location Manager.");
        service_app_exit();
    }

    if(location_manager_set_service_state_changed_cb(location_manager, location_state_changed_callback, NULL) != LOCATIONS_ERROR_NONE)
    {
        dlog_print(DLOG_DEBUG, LOG_TAG, "setup_location_manager: Failed to register service_state_changed callback for the Location Manager.");
        service_app_exit();
    }

    if(location_manager_set_position_updated_cb(location_manager, location_data_updated_callback, 1, NULL) != LOCATIONS_ERROR_NONE)
    {
        dlog_print(DLOG_DEBUG, LOG_TAG, "setup_location_manager: Failed to register location_updated callback for the Location Manager.");
        service_app_exit();
    }

        //THE LOGGER SHOWS THIS ON THE SCREEN
    dlog_print(DLOG_DEBUG, LOG_TAG, "setup_location_manager: Location Manager has been initialized successfully.");
}

void start_location_manager()
{
    handle_start_location_result(location_manager_start(location_manager));
}

void handle_start_location_result(int start_location_result)
{
    switch(start_location_result)
    {
        //Location Settings for the device are OFF
        case LOCATIONS_ERROR_GPS_SETTING_OFF:
            dlog_print(DLOG_DEBUG, LOG_TAG, "handle_location_manager_start_result: Please turn on the GPS Settings.");
            //service_app_exit();
            break;

        //Location Service is unavailable
        case LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE:
            dlog_print(DLOG_DEBUG, LOG_TAG, "handle_location_manager_start_result: Location Service is currently unavailable. Please try again later.");
            //service_app_exit();
            break;

        //Location Service not supported
        case LOCATIONS_ERROR_NOT_SUPPORTED:
            dlog_print(DLOG_DEBUG, LOG_TAG, "handle_location_manager_start_result: Location Service is not supported on the current device.");
            //service_app_exit();
            break;

        //Location Manager is started successfully
        case LOCATIONS_ERROR_NONE:
            //THE LOGGER SHOWS THIS LINE
            dlog_print(DLOG_DEBUG, LOG_TAG, "handle_location_manager_start_result: Location Manager has been started working.");
            break;
    }
}

//LOGGER DOES NOT SHOW ANYTHING FROM HERE ONWARDS
void location_state_changed_callback(location_service_state_e state, void *user_data)
{
    dlog_print(DLOG_DEBUG, LOG_TAG, "location_state_changed_callback: Location Service State: %s", state);
    location_service_state = state;
    if (state == LOCATIONS_SERVICE_ENABLED)
    {
        dlog_print(DLOG_DEBUG, LOG_TAG, "location_state_changed_callback: Location Service is enabled now.");
        get_location_information();
    }
}

日志文件显示与位置相关的以下行:

  1. setup_location_manager:位置管理器已成功初始化。

  2. handle_location_manager_start_result:位置管理器已开始工作。

在此之后,我没有收到来自 location_state_changed_callback 的任何更新。重新检查代码的source 也没有帮助。

【问题讨论】:

    标签: location tizen tizen-native-app


    【解决方案1】:

    位置API的使用是正确的,位置管理器的初始化也成功了。如果您可以发送日志以进行故障分析,这将对我们有所帮助。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-02
    • 2021-09-07
    相关资源
    最近更新 更多