Tizen本机服务:无法获取位置

问题描述 投票:0回答:1

我正在尝试在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个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.