Problem: When using the PersistedContent Monkey C API to launch an activity enriched with one waypoint navigation information from within a Widget, the activity gets started, but no navigation information is taken over.
Same behaviour does work for Courses or when the same Waypoint (Location/Favorite) is selected from an activity navigation menu manually.
Precondition: widget did download a fit file with locations and content type Fit using the Webrequest API to a http webserver
Further observations:
- Works on Edge830: Feature is working as expected on the Edge830 device (9.75 firmware)
- Not a name/id matching issue: The bug does not target to address the issue of name/id matching
- Same behaviour does work for Course type
- Works when the same Waypoint (Location/Favorite) is selected from an activity navigation menu manually.
Code:
function launchWaypointByName(waypointName as String) as Boolean {
if (!(Toybox has :PersistedContent) || !(PersistedContent has :getAppWaypoints)) {
return false;
}
var waypoints = PersistedContent.getAppWaypoints();
if (waypoints == null) {
return false;
}
var waypoint = waypoints.next();
while (waypoint != null) {
// take first matching object
if (waypoint.getName().equals(waypointName)) {
try {
// Check if toIntent method exists (API 2.3.0+)
if (waypoint has :toIntent) {
var intent = waypoint.toIntent();
if (intent != null) {
System.exitTo(intent);
return true;
}
}
System.println("Waypoint toIntent() not available or returned null");
return false;
} catch (ex) {
System.println("Error launching waypoint: " + ex.getErrorMessage());
return false;
}
}
waypoint = waypoints.next();
}
return false;
}