언어 설정

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 11월, 2019

Responses

6 댓글
chua enze

Hi, have you manage to fix this issue? I realise that sometimes I manage to get the location state change callback to work. 
However there are other times where it doesn't work. It's really frustrating ! 

Slawek Kowalski

Did you add privileage location to tizen-manifest.xml?

And make sure Location is enabled in Settings/Connectivites.

chua enze

Hi @Slawek Kowalski, Yes I have added the privileage to tizen-manifest and I have enabled the location. 
The issue with this is, sometimes the callback works. Other time it doesn't work! 

I have set position updated call back too and put a Log Tag at there. Sometimes the callbacks gets called. Other times, it didn't get called as well. 

 

https://docs.tizen.org/application/native/tutorials/feature/best-practice-battery

By looking at the image, I am guessing once the get location becomes unavailable, the location_manager would be stop. 

Do you have a fix to this issue? 

Alexia Amber

I'm sorry to hear about your situation. Your code snippet seems correct, but nothing is being logged from the location_state_changed_callback function. 

 

Charles

Thx alot. I understand 

abraham haskins

Thanks for your answer. My problem is solved