I am currently working on a Golf Scorecard counter. The counter as such works fine, but I have problems with the recording of an activity.
In a first attempt from last week it worked and the activity was even automatically uploaded to Garmin connect. In the present version, it works fine on the simulator but it crashes on the fenix 3 and shows the IQ icon with a yellow "!" sign when I start (or try to start) the activity.
The app loads fine, works fine as long as I don't start the recording, but once I select a "Start new round" from the menu and execute the following code, it crashes if it is the first time that the app is executed on the device.
When I open the app again, I can select the same menu item, the app does NOT crash this time, but it doesn't start to record the activity either. It continues to work normally with the inly exception that it refuses to start a recording.
Here is the MenuDelegate:
class Golf_SCMenuDelegate extends Ui.MenuInputDelegate {
function onMenuItem(item) {
if (item == :item_start_rec) {
startRound();
}
return true;
}
}
Now here's the code that is called from the MenuDelegate:
function startRound() {
if( ( session == null ) || ( session.isRecording() == false ) ) {
session = Rec.createSession({:name=>"Golf", :sport=>Rec.SPORT_GENERIC, :subsport=>Rec.SUB_SPORT_GENERIC});
strokes = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ];
hole = 1;
session.start();
Ui.requestUpdate();
}
}
The Position tracking is switched on already when the app is loaded, without any problems, using
Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
I would be very grateful if someone could come up with ideas and instructions.