Current Location?

How do I get the current GPS location in a watch-face app. I'm using SDK 2.1.3 (the latest version asof today)?

I've tried :
Position.enableLocationEvents(Position.LOCATION_ONE_SHOT);
var posInfo = Position.getInfo();

but on the simulator I get the following error on stdout:
Permission required
Permission Required
Failed invoking <symbol>


I also tried:
Activity.getActivityInfo();
but it returns null.
  • How do I get the current GPS location in a watch-face app. I'm using SDK 2.1.3 (the latest version asof today)?

    I've tried :
    Position.enableLocationEvents(Position.LOCATION_ONE_SHOT);
    var posInfo = Position.getInfo();

    but on the simulator I get the following error on stdout:
    Permission required
    Permission Required
    Failed invoking <symbol>



    You are getting a permission error because watch faces are not allowed to request 'live' GPS positions; neither continuous or one-time are allowed.

    I also tried:
    Activity.getActivityInfo();
    but it returns null.


    This is the proper way for a watch face to retrieve the position, though it will be the last position known position of the watch. It will be null in the simulator until you simulate data from the menu; Simulation -> Fit Data -> Simulate Data.

    For the real device you will want to ensure you handle a null position as I believe the last known position will be null following a watch reset.

    Cheers,
    Douglas
  • current location in watch face

    Hi,
    for watch faces the following code will do the trick to get the current location.
    ...
    var curLoc = Activity.getActivityInfo().currentLocation;
    if (curLoc != null) {
    long = curLoc.toDegrees()[1].toFloat();
    lat= curLoc.toDegrees()[0].toFloat();
    ...