I am trying to get location from the Tizen.Location.Locator using the GetLocation method but I'm getting an exception. The weird part is that when I catch the exception in the catch block of the code, there's no description available about the exception since it is being treated as a "bool" by the IDE and when I try to get the description by myException.Message property in the catch block, of course I get another error related to conversion of that bool variable (member reference base type 'bool' is not a structure or union). When I tried catching all exceptions (related to the method) in separate blocks, it showed that there's an InvalidOperationException. It may look weird but the exception is being shown as a "bool" variable in the catch block.
I am using:
- Visual Studio 2017
- Emulator of Wearable 4.0
- Have already granted the privileges of location, also added the location feature in the manifest file.
Here's my code:
private static GpsSatellite gpsSatellite = new GpsSatellite(locator); private static Locator locator = new Locator(LocationType.Gps); try { if (locator != null) { // Starts the Locator locator.Start(); //Get Location Location currentLocation = locator.GetLocation(); // Exception thrown from here locationAccessModel.ErrorMessage = ""; //Update View latitudeValue.Text = locationAccessModel.CurrentLocation.Latitude.ToString(); longitudeValue.Text = locationAccessModel.CurrentLocation.Longitude.ToString(); } } catch (InvalidOperationException exception) { // Exception handling locationAccessModel.ErrorMessage = exception.Message; // Update View }
The above code is not showing any ServiceStateChanged event registered, but I've also tried that before the locator.Start() method, but got no luck.
Have spent so many time but couldn't figure out what I'm doing wrong.