Languages

Menu
Sites
Language
Unable to get location

I am trying to get location on my Gear S3 Frontier watch. After enabling the location service I'm unable to get the location using the code below:

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();
	}
}

 

The log file shows the folliwng lines related to Location:

 

1. setup_location_manager: Location Manager has been initialized successfully.

2. handle_location_manager_start_result: Location Manager has been started working.

 

After this I don't get any  update from the 'location_state_changed_callback'. Someone please guide me what I'm doing wrong here.

Edited by: Itban Saeed on 25 Nov, 2019