ActivitySensor
ActivitySensor
ActivitySensor
ActivitySensor
Class
Definition
Represents an activity sensor that provides the activity and status of a sensor.
For an example implementation, see the activity sensor sample.
public : sealed class ActivitySensor : IActivitySensorpublic sealed class ActivitySensor : IActivitySensorPublic NotInheritable Class ActivitySensor Implements IActivitySensor// You can use this class in JavaScript.
- Attributes
| 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
In order to use ActivitySensor, you need to define the activity device capability in your app manifest file.
<Capabilities>
<DeviceCapability Name="activity"/>
</Capabilities>
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
Gets the minimum report interval supported by the sensor.
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 minimum report interval supported by the sensor.
PowerInMilliwatts PowerInMilliwatts PowerInMilliwatts PowerInMilliwatts
Gets the power in milliwatts 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 power in milliwatts that the sensor consumes.
SubscribedActivities SubscribedActivities SubscribedActivities SubscribedActivities
Gets the list of activity types that the sensor pledges to perform.
public : IVector<ActivityType> SubscribedActivities { get; }public IList<ActivityType> SubscribedActivities { get; }Public ReadOnly Property SubscribedActivities As IList<ActivityType>// You can use this property in JavaScript.
- Value
- IVector<ActivityType> IList<ActivityType> IList<ActivityType> IList<ActivityType>
The list of ActivityType -typed values for the activity types that the sensor pledges to perform.
SupportedActivities SupportedActivities SupportedActivities SupportedActivities
Gets the list of activity types that the sensor supports.
public : IVectorView<ActivityType> SupportedActivities { get; }public IReadOnlyList<ActivityType> SupportedActivities { get; }Public ReadOnly Property SupportedActivities As IReadOnlyList<ActivityType>// You can use this property in JavaScript.
- Value
- IVectorView<ActivityType> IReadOnlyList<ActivityType> IReadOnlyList<ActivityType> IReadOnlyList<ActivityType>
The list of ActivityType -typed values for the activity types that the sensor supports.
Methods
FromIdAsync(String) FromIdAsync(String) FromIdAsync(String) FromIdAsync(String)
Asynchronously obtains the sensor from its identifier.
public : static IAsyncOperation<ActivitySensor> FromIdAsync(PlatForm::String deviceId)public static IAsyncOperation<ActivitySensor> FromIdAsync(String deviceId)Public Static Function FromIdAsync(deviceId As String) As IAsyncOperation( Of ActivitySensor )// You can use this method in JavaScript.
- deviceId
- PlatForm::String String String String
Returns the ActivitySensor object from its identifier.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
activity
|
GetCurrentReadingAsync() GetCurrentReadingAsync() GetCurrentReadingAsync() GetCurrentReadingAsync()
Asynchronously gets the current sensor reading.
public : IAsyncOperation<ActivitySensorReading> GetCurrentReadingAsync()public IAsyncOperation<ActivitySensorReading> GetCurrentReadingAsync()Public Function GetCurrentReadingAsync() As IAsyncOperation( Of ActivitySensorReading )// You can use this method in JavaScript.
Asynchronously returns a ActivitySensorReading object that represents info about the sensor.
GetDefaultAsync() GetDefaultAsync() GetDefaultAsync() GetDefaultAsync()
Asynchronously obtains the default sensor.
public : static IAsyncOperation<ActivitySensor> GetDefaultAsync()public static IAsyncOperation<ActivitySensor> GetDefaultAsync()Public Static Function GetDefaultAsync() As IAsyncOperation( Of ActivitySensor )// You can use this method in JavaScript.
Asynchronously returns a ActivitySensor object that represents the default sensor.
| 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 the device selector, if it exists; otherwise, null.
GetSystemHistoryAsync(DateTime) GetSystemHistoryAsync(DateTime) GetSystemHistoryAsync(DateTime) GetSystemHistoryAsync(DateTime)
Asynchronously gets sensor readings from a specific time.
public : static IAsyncOperation<IVectorView<ActivitySensorReading>> GetSystemHistoryAsync(DateTime fromTime)public static IAsyncOperation<IReadOnlyList<ActivitySensorReading>> GetSystemHistoryAsync(DateTimeOffset fromTime)Public Static Function GetSystemHistoryAsync(fromTime As DateTimeOffset) As IAsyncOperation( Of IReadOnlyListActivitySensorReading )// You can use this method in JavaScript.
- fromTime
- DateTime DateTimeOffset DateTimeOffset DateTimeOffset
The time at which to get sensor readings.
Asynchronously returns a list of ActivitySensorReading objects that represent info about the sensor.
- See Also
GetSystemHistoryAsync(DateTime, TimeSpan) GetSystemHistoryAsync(DateTime, TimeSpan) GetSystemHistoryAsync(DateTime, TimeSpan) GetSystemHistoryAsync(DateTime, TimeSpan)
Asynchronously gets sensor readings from a specific time and duration.
public : static IAsyncOperation<IVectorView<ActivitySensorReading>> GetSystemHistoryAsync(DateTime fromTime, TimeSpan duration)public static IAsyncOperation<IReadOnlyList<ActivitySensorReading>> GetSystemHistoryAsync(DateTimeOffset fromTime, TimeSpan duration)Public Static Function GetSystemHistoryAsync(fromTime As DateTimeOffset, duration As TimeSpan) As IAsyncOperation( Of IReadOnlyListActivitySensorReading )// You can use this method in JavaScript.
- fromTime
- DateTime DateTimeOffset DateTimeOffset DateTimeOffset
The time at which to get sensor readings.
- duration
- TimeSpan TimeSpan TimeSpan TimeSpan
The time span during which to get sensor readings.
Asynchronously returns a list of ActivitySensorReading objects that represent info about the sensor.
- See Also
Events
ReadingChanged ReadingChanged ReadingChanged ReadingChanged
Occurs each time the sensor reports a new sensor reading.
public : event TypedEventHandler ReadingChanged<ActivitySensor, ActivitySensorReadingChangedEventArgs>public event TypedEventHandler ReadingChanged<ActivitySensor, ActivitySensorReadingChangedEventArgs>Public Event ReadingChanged<ActivitySensor, ActivitySensorReadingChangedEventArgs>// You can use this event in JavaScript.
Remarks
When you add a callback function, you receive an initial callback. However, there is a case where you will not receive this initial callback.
- Add a callback function.
- Remove the callback function.
- Add another callback function (or the original one a second time)
In this sequence of events, the second callback function will not receive the initial callback. It will receive callback notifications normally when the ActivitySensor reports a new reading; only the initial callback will be missed.