GPS handling on Windows Phone

34 views
Skip to first unread message

Mario Barón

unread,
Mar 11, 2014, 8:48:47 AM3/11/14
to codenameone...@googlegroups.com
Hey guys,

I have a question, my app needs to get the user's location using the GPS sensor and then process it to do other stuff with it. I've mainly tried this on Android and it works perfectly, but I need to make sure this works on Windows Phone too but by the looks of it, the code I'm using doesn't even seem to try to look for the location even though I have location services on. I'm using the following code in order to get it: 

public Location getLocation() {
    Location loc = null;
    try {
      final LocationManager mylocLocationManager = LocationManager.getLocationManager();
      
      loc = mylocLocationManager.getCurrentLocationSync(60000);
      
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    
    return loc;
  }

Can you please help me with this?


Thanks. 

Shai Almog

unread,
Mar 11, 2014, 3:39:22 PM3/11/14
to codenameone...@googlegroups.com
Hi,
does it return the wrong value?
Location is implemented on Windows Phone so I'm not sure what you are seeing. Its possible that the location services are turned on but the device might not have proper signal to give you a proper location.

Mario Barón

unread,
Mar 12, 2014, 8:38:38 AM3/12/14
to codenameone...@googlegroups.com
Hey Shai, 

thanks for your response. It seems that the error wasn't generated with obtaining the location but with a WS consumption I was doing prior to calling this code. Although I did noticed that location is only obtained using the GPS sensor, I thought it was supposed to use data connection when the GPS wasn't available. I'm using the getCurrentLocationSync(long) method instead of the listener approach, maybe it's only with this method? If so, do you have plans to incorporate location through data connection with this method soon?


Thanks a million.

Shai Almog

unread,
Mar 12, 2014, 1:28:23 PM3/12/14
to codenameone...@googlegroups.com
Hi,
I don't recall what we do there in great detail. We should return a network location if possible on the device, but I'm not sure what's available on Windows Phone.
Reply all
Reply to author
Forward
0 new messages