Acknowledged

Logging SPORT_VOLLEYBALL crashes the watch

I am the developer of the Volleyball App (Volleyball | Garmin Connect IQ). When I try to record an Activity as SPORT_VOLLEYBALL, it fails and crashes the App on the watch. The documentation does not contain SPORT_VOLLEBALL, but it seems to exist anyway (documentation on the SPORT Types is outdated).

Is there a way for me to record a volleyball activity (if the watch supports it)? Right now I do the following, which always seems to log as SPORT_GENERIC, but at least it does not crash the watch:

using Toybox.ActivityRecording as Record;
if (Record has :SPORT_VOLLEYBALL) {
  session = Record.createSession({:name=>"Volleyball", 
                                  :sport=>Record.SPORT_VOLLEYBALL,
                                  :subSport=>Record.SUB_SPORT_EXERCISE});
} else {
    session = Record.createSession({:name=>"Volleyball", 
                                    :sport=>Record.SPORT_GENERIC, 
                                    :subSport=>Record.SUB_SPORT_EXERCISE});
}



Parents
  • Your app is crashing because there is no constant ActivityRecording.SPORT_VOLLEYBALL. If you check the debug output in the vscode console or the contents of CIQ_LOG.yml, you'll likely see the symbol not found error on the line referencing that symbol. This is expected.

    The list of SPORT_* constants in the ActivityRecording module is incomplete and they are deprecated. If you want to specify SPORT_VOLLEYBALL, you need to reference the symbol from the Activity module. 

    If you need to support devices that don't have the constants in the Activity module (i.e., devices prior to 3.2.0), you can fall back to those in the ActivityRecording module. The following should work with all devices that have ActivityRecording support (necessary for the createSession call).

    import Toybox.Activity;
    import Toybox.ActivityRecording;
    
    
    // ...
    
      var sport;
      var subSport;
    
      if (Activity has :SPORT_VOLLEYBALL) {
          // 4.1.6 and later
          sport = Activity.SPORT_VOLLEYBALL;
          subSport = Activity.SUB_SPORT_EXERCISE;
      } else if (Activity has :SPORT_GENERIC) {
          // 3.2.0 and later
          sport = Activity.SPORT_GENERIC;
          subSport = Activity.SUB_SPORT_EXERCISE;
      } else {
          // 1.0.0 and later
          sport = ActivityRecording.SPORT_GENERIC;
          subSport = ActivityRecording.SUB_SPORT_EXERCISE;
      }
    
      session = ActivityRecording.createSession({
          :name => "Volleyball", 
          :sport => sport,
          :subSport => subSport
      });

Comment
  • Your app is crashing because there is no constant ActivityRecording.SPORT_VOLLEYBALL. If you check the debug output in the vscode console or the contents of CIQ_LOG.yml, you'll likely see the symbol not found error on the line referencing that symbol. This is expected.

    The list of SPORT_* constants in the ActivityRecording module is incomplete and they are deprecated. If you want to specify SPORT_VOLLEYBALL, you need to reference the symbol from the Activity module. 

    If you need to support devices that don't have the constants in the Activity module (i.e., devices prior to 3.2.0), you can fall back to those in the ActivityRecording module. The following should work with all devices that have ActivityRecording support (necessary for the createSession call).

    import Toybox.Activity;
    import Toybox.ActivityRecording;
    
    
    // ...
    
      var sport;
      var subSport;
    
      if (Activity has :SPORT_VOLLEYBALL) {
          // 4.1.6 and later
          sport = Activity.SPORT_VOLLEYBALL;
          subSport = Activity.SUB_SPORT_EXERCISE;
      } else if (Activity has :SPORT_GENERIC) {
          // 3.2.0 and later
          sport = Activity.SPORT_GENERIC;
          subSport = Activity.SUB_SPORT_EXERCISE;
      } else {
          // 1.0.0 and later
          sport = ActivityRecording.SPORT_GENERIC;
          subSport = ActivityRecording.SUB_SPORT_EXERCISE;
      }
    
      session = ActivityRecording.createSession({
          :name => "Volleyball", 
          :sport => sport,
          :subSport => subSport
      });

Children
No Data