Detect sport type from datafield

How to check if running/cycling/walking etc. has been chosen for the activity? It would also help to be able to get the name of the sport type (e.g. MTB).
I'd like to set a "target speed" for different sport types (like the virtual partner) to be able to use the same datafield for different sports.

  • I'm not sure why it is part of the UserProfile module, but the function UserProfile.getCurrentSport() can be used to get the current sport as one of UserProfile.RW_ZONE_SPORT_GENERIC, RW_ZONE_SPORT_RUNNING, RW_ZONE_SPORT_BIKING, or RW_ZONE_SPORT_SWIMMING.
  • Travis - you can get the HZ zone, but not the actual sport in some cases. Just the big 3 (running/biking/swimming). Not walking, hiking, any many of the 19 defined sports.
  • Probably that API should have been named something more detailed like "getCurrentHeartRateZoneSport()". It is specifically intended to be paired with the UserProfile.getHeartRateZones() API. It will give you the current sport only in relation to the sets of heart rate zones a product stores for the user profile. Some only store one and will always return Running or Generic. This API is probably not reliable in many contexts for getting the current sport for other purposes.
  • Thanks, this is much better than nothing ;)

    No I am able to have at least three useful target speeds, so my datafield could also be used for other activities than running..
  • I am trying to figure out whether situation is similar for widgets i.e. how to detect sport type for latest activity and current activity? Is there any reliable way of doing it?