Pedometer Pedometer Pedometer Pedometer Class

Definition

Provides an interface for a pedometer to measure the number of steps taken.

For an example implemenation, see the pedometer sample.

public : sealed class Pedometer : IPedometer, IPedometer2public sealed class Pedometer : IPedometer, IPedometer2Public NotInheritable Class Pedometer Implements IPedometer, IPedometer2// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Note

This class is not supported in JavaScript

Properties

DeviceId DeviceId DeviceId DeviceId

Gets the device identifier.

public : PlatForm::String DeviceId { get; }public string DeviceId { get; }Public ReadOnly Property DeviceId As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

The device identifier.

MinimumReportInterval MinimumReportInterval MinimumReportInterval MinimumReportInterval

The smallest report interval that is supported by this pedometer.

public : unsigned int MinimumReportInterval { get; }public uint MinimumReportInterval { get; }Public ReadOnly Property MinimumReportInterval As uint// You can use this property in JavaScript.
Value
unsigned int uint uint uint

The smallest ReportInterval supported by the sensor.

PowerInMilliwatts PowerInMilliwatts PowerInMilliwatts PowerInMilliwatts

Gets the power that the sensor consumes.

public : double PowerInMilliwatts { get; }public double PowerInMilliwatts { get; }Public ReadOnly Property PowerInMilliwatts As double// You can use this property in JavaScript.
Value
double double double double

The amount of power consumed in milliwatts.

ReportInterval ReportInterval ReportInterval ReportInterval

Gets or sets the current report interval for the pedometer.

public : unsigned int ReportInterval { get; set; }public uint ReportInterval { get; set; }Public ReadWrite Property ReportInterval As uint// You can use this property in JavaScript.
Value
unsigned int uint uint uint

The current report interval.

Remarks

The report interval is specified in milliseconds.

The report interval will be set to a default value that will vary based on the sensor driver’s implementation. If your app does not want to use this default value, you should set the report interval to a non-zero value prior to registering an event handler or requesting a PedometerReading. The sensor will then attempt to allocate resources to satisfy the application’s requirements but the sensor also has to balance the needs of other apps using the sensor.

Changes to the report interval after an event handler has been registered or after you check the sensor history may apply to the delivery of subsequent sensor readings.

Conversely, when an application is finished with the sensor, it should explicitly return the sensor to its default report interval by setting it to zero. This is important for power conservation, especially when using a language that may keep the sensor object active for an indefinite period prior to garbage collection.

Your application should consult the MinimumReportInterval property prior to setting the report interval to ensure that the sensor can honor the requested report interval. Setting a value below the minimum supported interval will either trigger an exception or have undefined results.

Setting a value of zero requests the driver to use its default report interval. As with requesting a specific interval, the driver may choose a different interval based on other client requests and internal logic.

Methods

FromIdAsync(String) FromIdAsync(String) FromIdAsync(String) FromIdAsync(String)

Obtains the pedometer from its identifier.

public : static IAsyncOperation<Pedometer> FromIdAsync(PlatForm::String deviceId)public static IAsyncOperation<Pedometer> FromIdAsync(String deviceId)Public Static Function FromIdAsync(deviceId As String) As IAsyncOperation( Of Pedometer )// You can use this method in JavaScript.
Parameters
deviceId
PlatForm::String String String String

The sensor identifier.

Returns
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
activity

GetCurrentReadings() GetCurrentReadings() GetCurrentReadings() GetCurrentReadings()

Gets the current step information from the pedometer sensor.

public : IMapView<PedometerStepKind, PedometerReading> GetCurrentReadings()public IReadOnlyDictionary<PedometerStepKind, PedometerReading> GetCurrentReadings()Public Function GetCurrentReadings() As IReadOnlyDictionary( Of PedometerStepKind, PedometerReading )// You can use this method in JavaScript.
Returns
IMapView<PedometerStepKind, PedometerReading> IReadOnlyDictionary<PedometerStepKind, PedometerReading> IReadOnlyDictionary<PedometerStepKind, PedometerReading> IReadOnlyDictionary<PedometerStepKind, PedometerReading>

A collection of the step information available from the sensor.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

GetDefaultAsync() GetDefaultAsync() GetDefaultAsync() GetDefaultAsync()

Asynchronously obtains the default pedometer.

public : static IAsyncOperation<Pedometer> GetDefaultAsync()public static IAsyncOperation<Pedometer> GetDefaultAsync()Public Static Function GetDefaultAsync() As IAsyncOperation( Of Pedometer )// You can use this method in JavaScript.
Returns
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
activity

GetDeviceSelector() GetDeviceSelector() GetDeviceSelector() GetDeviceSelector()

Gets the device selector.

public : static PlatForm::String GetDeviceSelector()public static string GetDeviceSelector()Public Static Function GetDeviceSelector() As string// You can use this method in JavaScript.
Returns
PlatForm::String string string string

Returns the device selector, if it exists; otherwise null.

GetReadingsFromTriggerDetails(SensorDataThresholdTriggerDetails) GetReadingsFromTriggerDetails(SensorDataThresholdTriggerDetails) GetReadingsFromTriggerDetails(SensorDataThresholdTriggerDetails) GetReadingsFromTriggerDetails(SensorDataThresholdTriggerDetails)

Gets readings from the trigger details in background task.

public : static IVectorView<PedometerReading> GetReadingsFromTriggerDetails(SensorDataThresholdTriggerDetails triggerDetails)public static IReadOnlyList<PedometerReading> GetReadingsFromTriggerDetails(SensorDataThresholdTriggerDetails triggerDetails)Public Static Function GetReadingsFromTriggerDetails(triggerDetails As SensorDataThresholdTriggerDetails) As IReadOnlyList( Of PedometerReading )// You can use this method in JavaScript.
Parameters
Returns
IVectorView<PedometerReading> IReadOnlyList<PedometerReading> IReadOnlyList<PedometerReading> IReadOnlyList<PedometerReading>

The collection of pedometer data retrieved from the trigger details.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Remarks

SensorDataThresholdTriggerDetails objects are designed to be independent of the sensor that activated the background trigger. This enables you to support all of the sensors your are interested in with a single background task. In order to support this methodology, you need to define this method in all of your sensors that extract data from the background trigger.

GetSystemHistoryAsync(DateTime) GetSystemHistoryAsync(DateTime) GetSystemHistoryAsync(DateTime) GetSystemHistoryAsync(DateTime)

Asynchronously gets sensor readings from a specific time.

public : static IAsyncOperation<IVectorView<PedometerReading>> GetSystemHistoryAsync(DateTime fromTime)public static IAsyncOperation<IReadOnlyList<PedometerReading>> GetSystemHistoryAsync(DateTimeOffset fromTime)Public Static Function GetSystemHistoryAsync(fromTime As DateTimeOffset) As IAsyncOperation( Of IReadOnlyListPedometerReading )// You can use this method in JavaScript.
Parameters
fromTime
DateTime DateTimeOffset DateTimeOffset DateTimeOffset

The time for which you want to retrieve the reading.

Returns
IAsyncOperation<IVectorView<PedometerReading>> IAsyncOperation<IReadOnlyList<PedometerReading>> IAsyncOperation<IReadOnlyList<PedometerReading>> IAsyncOperation<IReadOnlyList<PedometerReading>>

Asynchronously returns a list of PedometerReading objects that represent info about the sensor.

See Also

GetSystemHistoryAsync(DateTime, TimeSpan) GetSystemHistoryAsync(DateTime, TimeSpan) GetSystemHistoryAsync(DateTime, TimeSpan) GetSystemHistoryAsync(DateTime, TimeSpan)

Asynchronously gets pedometer readings from a specific time and duration.

public : static IAsyncOperation<IVectorView<PedometerReading>> GetSystemHistoryAsync(DateTime fromTime, TimeSpan duration)public static IAsyncOperation<IReadOnlyList<PedometerReading>> GetSystemHistoryAsync(DateTimeOffset fromTime, TimeSpan duration)Public Static Function GetSystemHistoryAsync(fromTime As DateTimeOffset, duration As TimeSpan) As IAsyncOperation( Of IReadOnlyListPedometerReading )// You can use this method in JavaScript.
Parameters
fromTime
DateTime DateTimeOffset DateTimeOffset DateTimeOffset

The time for which you want to retrieve the reading.

duration
TimeSpan TimeSpan TimeSpan TimeSpan

The duration over which you want to retrieve data.

Returns
IAsyncOperation<IVectorView<PedometerReading>> IAsyncOperation<IReadOnlyList<PedometerReading>> IAsyncOperation<IReadOnlyList<PedometerReading>> IAsyncOperation<IReadOnlyList<PedometerReading>>

Asynchronously returns a list of PedometerReading objects that represent info about the sensor.

See Also

Events

ReadingChanged ReadingChanged ReadingChanged ReadingChanged

Occurs each time the pedometer reports a new value.

public : event TypedEventHandler ReadingChanged<Pedometer,  PedometerReadingChangedEventArgs>public event TypedEventHandler ReadingChanged<Pedometer,  PedometerReadingChangedEventArgs>Public Event ReadingChanged<Pedometer,  PedometerReadingChangedEventArgs>// You can use this event in JavaScript.

Remarks

An application may register this event handler to obtain sensor readings. The application must establish a desired ReportInterval. This sets the frequency of the ReadingChanged event.