Module: Toybox.UserProfile

Overview

The UserProfile module will allow apps to access user information.

The module contains the GENDER_* enum to retrieve gender information from the user profile. The HR_ZONE_SPORT_* enum also provides constants for defining different sport type. This is used to retrieve Heart Rate Zones specific to that sport.

Example:

Simple UserProfile module use

using Toybox.UserProfile;

var profile = UserProfile.getProfile();
System.out.println("The user was born in " + profile.birthYear);

Since:

API Level 1.0.0

Requires Permission:

  • UserProfile

Classes Under Namespace

Classes: Profile, UserActivity, UserActivityHistoryIterator

Constant Summary

Gender

Since:

API Level 1.0.0

Name Value Since Description
GENDER_FEMALE 0

API Level 1.0.0

GENDER_MALE 1

API Level 1.0.0

GENDER_UNSPECIFIED 2

API Level 4.2.3

SportHrZone

Since:

API Level 1.0.0

Name Value Since Description
HR_ZONE_SPORT_GENERIC 0

API Level 1.2.6

HR_ZONE_SPORT_RUNNING 1

API Level 1.2.6

HR_ZONE_SPORT_BIKING 2

API Level 1.2.6

HR_ZONE_SPORT_SWIMMING 3

API Level 1.2.6

Instance Method Summary collapse

Instance Method Details

getCurrentSport() as UserProfile.SportHrZone

Return the sport for which the current activity retrieves heart rate zone thresholds.

If the active sport does not have sport specific zones, it will return HR_ZONE_SPORT_GENERIC.

Example:

using Toybox.UserProfile;
var profile = UserProfile.getCurrentSport();

Returns:

Since:

API Level 1.2.6

getCurrentSport2() as [ Activity.Sport, Activity.SubSport ]

Return the sport for the current activity.

Returns:

Since:

API Level 5.2.2

getFunctionalThresholdPower(sport as Activity.Sport) as Lang.Number or Null

Return the user's functional threshold power (FTP).

Parameters:

Example:

Use the SPORT_* enum to get the zone for that specific sport

using Toybox.UserProfile;
var thresholdPower = UserProfile.getFunctionalThresholdPower(Activity.SPORT_CYCLING);

Returns:

  • Lang.Number

    The FTP value for the requested sport. If the given sport does not have an FTP value configured, the value from a default sport will be given, or null will be returned on error.

Since:

API Level 5.2.2

getHeartRateZones(sport as UserProfile.SportHrZone) as Lang.Array<Lang.Number>

Retrieve an Array of the current heart rate zone threshold values in beats per minute (bpm)

The returned Array contains zone values as follows:

  • min zone 1 - The minimum heart rate threshold for zone 1

  • max zone 1 - The maximum heart rate threshold for zone 1

  • max zone 2 - The maximum heart rate threshold for zone 2

  • max zone 3 - The maximum heart rate threshold for zone 3

  • max zone 4 - The maximum heart rate threshold for zone 4

  • max zone 5 - The maximum heart rate threshold for zone 5

Parameters:

Example:

Use the HR_ZONE_SPORT_* enum to get the zone for that specific sport

using Toybox.UserProfile;
var genericZoneInfo = UserProfile.getHeartRateZones(UserProfile.HR_ZONE_SPORT_GENERIC);

Returns:

  • Lang.Array

    An Array of zone thresholds for the requested sport.

Since:

API Level 1.2.6

getHeartRateZones2(sport as Activity.Sport) as Lang.Array<Lang.Number> or Null

Retrieve an Array of the current heart rate zone threshold values in beats per minute (bpm)

The returned Array contains zone values as follows:

  • min zone 1 - The minimum heart rate threshold for zone 1

  • max zone 1 - The maximum heart rate threshold for zone 1

  • max zone 2 - The maximum heart rate threshold for zone 2

  • max zone 3 - The maximum heart rate threshold for zone 3

  • max zone 4 - The maximum heart rate threshold for zone 4

  • max zone 5 - The maximum heart rate threshold for zone 5

Parameters:

  • sport(Activity.Sport)

    The sport that zones are being requested for. Should be a SPORT_* value.

Example:

Use the HR_ZONE_SPORT_* enum to get the zone for that specific sport

using Toybox.UserProfile;
var zoneInfo = UserProfile.getHeartRateZones2(Activity.SPORT_GENERIC);

Returns:

  • Lang.Array

    An Array of zone thresholds for the requested sport. If the given sport does not have heart rate zones configured, zones for a default sport will be returned, or null will be returned on error.

Since:

API Level 5.2.2

getPowerZones(sport as Activity.Sport) as Lang.Array<Lang.Number> or Null

Retrieve an Array of the current power zone threshold values in watts (W)

Parameters:

  • sport(Activity.Sport)

    The sport that zones are being requested from. Should be a SPORT_* value.

Example:

Use the SPORT_* enum to get the zone for that specific sport

using Toybox.UserProfile;
var zoneInfo = UserProfile.getPowerZones(Activity.SPORT_RUNNING);

Returns:

  • Lang.Array

    An Array of zone thresholds for the requested sport. If the given sport does not have power zones configured, zones for a default sport will be returned, or null will be returned on error.

Since:

API Level 5.2.2

getProfile() as UserProfile.Profile

Retrieve the current Profile object.

Example:

using Toybox.UserProfile;
var profile = UserProfile.getProfile();

Returns:

Since:

API Level 1.0.0

getUserActivityHistory() as UserProfile.UserActivityHistoryIterator

Get an iterator for Activity history for the user

Example:

Shows the use of UserActivityHistoryIterator

using Toybox.UserProfile;
using Toybox.System;

// get a UserActivityHistoryIterator object
var userActivityIterator = UserProfile.getUserActivityHistory();
var sample = userActivityIterator.next();                        // get the user activity data

while (sample != null) {
    System.println("Sample: " + sample.userActivityData);        // print the current sample
    sample = userActivityIterator.next();
}

Returns:

Since:

API Level 3.3.0


Generated Mar 10, 2026, 11:32:36 AM