Help with Toybox.Activity.getActivityInfo().currentLocation in a watchface

Former Member
Former Member
Hi.

I'm trying to use the last known location to calculate sunrise/sunset times for a watchface, as per the thread here.

As far as i can tell i'm doing everything correctly but getting nonsensical results. For example, in a function i have the following code+check ...

var loc = Toybox.Activity.getActivityInfo().currentLocation;
Sys.println("Location: " + loc);


... which i would have expected to return a two element array containing latitude and longitude (e.g. [-37.81400, 144.96332]), as per the comment here. Instead this prints "Location: Obj: 93", and attempting to use loc[0] and loc[1] in a calculation cause an UnexpectedTypeException: Expected Symbol, given Number error. So clearly i have no idea what currentLocation is actually returning, and the docs online aren't really much help.

When i put this on the watch and find GPS the whole thing crashes.

Does anyone know what's going on here? Happy to provide more information or code.