About a year ago, we wrote about how to work with the Lumia SensorCore SDK ( review , application creation ) - a special API for working with sensors on Lumia-devices. In Windows 10, on the basis of these and other developments in the universal Windows platform (UWP), we expanded the API for working with devices, adding new features for interacting with the user's context. Below we offer your attention to the report from the Build conference on this topic and the translation of the review article describing the new features.
In Windows 10, we are excited about the opportunity to present a number of new APIs for interacting with the context, which can help you create applications that improve the lives of users every day. This includes applications that can detect presence when a user approaches devices, applications that understand whether a user is walking or driving, applications that help users track their fitness performance, and many other scenarios. Using these APIs, you can anticipate user needs and proactively offer relevant personalized and relevant data or services to improve and facilitate their lives. This is quite a powerful thing for both consumer and corporate scenarios.

Determination of the type of activity
One of the new added APIs is the means for determining the type of activity (Activity Detection), which helps to clarify the context of the (re) movement of the user. These APIs are trying to understand what a person is doing on the basis of the current nature of the movement: walking, running, riding in a car or on a bicycle, in a stationary or “resting” state. The fixed state is returned when the device is with the user, and “rest” when the user has placed the device on a table or a fixed surface. You can also create background triggers and request a detailed history up to 30 days ago.
')
Several scenarios to use:
- Give information depending on the context of the movement (for example, adjust the pace of the playlist)
- Change the behavior of the application according to the context of the movement (for example, automatically adjust the focus if you understand what the user is shooting at the camera while walking or running)
- Tracking fitness and health data
- Navigation and maps
- Save energy (for example, avoid constantly polling the location or WiFi if the device is at rest or stationary)
The scheme of work with API is given below.
More details on the API for determining the type of activity are
described in MSDN , and sample code can be found in
the UWP SDK collection of examples .
Counting steps
Another useful addition is a pedometer that counts the number of user steps while walking or running. As in the case of determining the type of activity, information in the history is stored up to 30 days.
A typical application in which this functionality can be used is to track health and fitness data (without the need for additional (wearable) devices). A pedometer can also combine wearable device data and data from your device’s sensors with Windows.
An example of working with the API is shown below:
More information about the API work with a pedometer is
given in MSDN , and ready-made sample code is available in the
collection of examples .
Barometer and altitude sensor
To work with information about pressure (data from the barometer) and relative height (for example, change during lifting), we added, respectively, the API of the barometer and height.
Typical scenarios:
- Health and fitness: knowing the relative height, you can understand whether the user is moving up or down and take this into account when calculating the cost of calories
- Determine which floor the user is on when navigating indoors
- Weather prediction
An example of working with the API:
Barometer barometer = Barometer.GetDefault(); BarometerReading reading = barometer.GetCurrentReading(); double pressure = reading.StationPressureInHectopascals; barometer.ReadingChanged += ... Altimeter altimeter = Altimeter.GetDefault(); AltimeterReading altimeterReading = altimeter.GetCurrentReading(); double altitudeChange = altimeterReading.AltitudeChangeInMeters; altimeter.ReadingChanged += ...
Additional information:
Presence detection
We now also support an API for detecting presence with close and long range radii. Sensors of close action work at a distance of 2-3cm, in the far - they can detect presence at a distance of up to 12 meters.
Practical scenarios:
- Activating the device when the user approaches or shutdown when the user is deleted. For example, Surface Hub uses the API data to wake up when a person enters the meeting room, and off when all people have left.
- Automatically turn off the screen during a call
- Identify and ignore random keystrokes when it becomes clear that the device is in the user's pocket.
- Definition of gestures
An example of working with the proximity API is shown below:
using Windows.Devices.Sensors;
More information on the proximity API documentation can be found
in MSDN , and do not forget about the
finished example .
In addition to documentation, additional information (for example, on working with
our own sensors ) can also be found in
our report on creating context-aware UWP applications using sensors, which we told at the Build 2015 conference (also shown at the beginning of the translation).