Best practices

When designing applications that utilize the Lumia SensorCore SDK, please
consider the following guidelines and comments.

Quick checklist

  • Verify that the device supports SensorCore SDK. If it does not, hide the SensorCore dependent functionality unless it is essential for the application.
  • Check if the user has motion data and location services enabled. If not, provide an easy way to enable them. Fail gracefully if the user chooses not to.
  • Handle the situation where the user configures motion data or disables location services while the application is still running.
  • Start and stop SensorCore when the user navigates to/away from the app.
  • Be prepared to a situation where SensorCore hasn't yet accumulated data to the device.
  • Be sensitive with the user's location and motion data, and obtain the user's express permission before uploading or sharing the information out from the device.

Provide users with an easy way to enable location services or motion data. Many users may have either location services or motion data disabled by default. Apps should provide users with an easy way to enable the necessary features for a better user experience.

Motion data is not available on all devices. Apps that utilize the SensorCore SDK can also be installed on devices that do not support SensorCore SDK functionalities. Apps should prepare for cases in which no sensor or sensor data is available. If an app has no functionality without SensorCore SDK, it should be stated in the app's description in the Windows Phone Store.

If the user has version 1.X of motion data settings in the device step counter, activity monitor only starts collecting data after the user has enabled motion data collection in system settings. If the user has just enabled motion data collection, there is no or very little history data available.

If the user has motion data settings 1.0, all motion data can be cleared by the user. If the user has motion data settings 2.0, only Places and Tracks related motion data can be cleared by the user. The developer must make sure that the app handles cases in which sensor data is cleared.

If motion data is set to Basic mode, remember the passive nature of Place Monitor and Track Point Monitor. Place Monitor and Track Point Monitor will not actively poll the user's location. Therefore, it might take several hours before the data gets updated. The frequency of history data is dependent on whether some other applications are currently using GPS or not. The user's environment will have an effect on data accuracy and update frequency. For example, in city areas, the data is more accurate and the frequency of updates is higher than in areas outside the city. In normal city conditions, you can expect to receive updates around every 500 meters for Track Point Monitor. With the Place Monitor, consider combining the data with more active positioning methods to create compelling apps.

Note the latency introduced by filtering. To improve Step Counter and activity detection accuracy, the sensor data is being filtered before it is made available through the API. This adds some latency to the step and activity detection. For example, Step Counter readings will be approximately 6-7 seconds “late”. Therefore, it is advisable to decrease the granularity of the data shown in UI, for example, rounding step count to nearest 50 or 100 steps.

Notice the granularity of Step counter history data. Step Counter history data is collected by the sensor every five minutes. Data collection is aligned with the system clock, i.e. always at the hour, five minutes past, ten minutes past, etc. This means that if you combine the data with Activity Monitor history data, you will be unable to get accurate measurements at the exact moments of activity changes. Note that the current reading polled from the Step Counter will always be up-to-date, not (up to) five minutes off.

Notice that the Step Counter data is absolute. Step counts and walking/running times returned by the Step Counter are total numbers since the last device factory reset or motion data clearing from motion data settings. If you need step counts and walking/running times since your application was first started, you will have to save the step count value you get the first time the application is started up. Save that value in your application persistent data storage. On subsequent application starts, poll the current value of the step count, and subtract the saved value to calculate the delta. In such cases, it is important to remember that the step count can be cleared by the user.

Try to reduce the usage of background processes. If possible, utilize history data collected by the sensors instead of polling or monitoring the sensors in background processes. The sensors collect data in a very power-efficient way, so make use of that whenever possible. The data is saved for 10 days. If it can be assumed that your application will be used at least once every 10th day, you could just collect the history data since the last time your application was used and not have to use background processes at all.

Be aware of system clock change behavior. Changing system clock manually, for example, because of daylight savings or traveling to another time zone, will have an effect on collected motion data. In case the clock is moved backwards, any data left “in the future” will get deleted. In case the clock is moved forwards, there will be gaps in the history data. Changing the date - even momentarily - for more than ten days will result in all the history data getting cleared.

Privacy is critical part of the system. The system relies on the user to enable Location and motion data for SensorCore to work. In case your application moves any location or motion data outside of the device to the backend, it is strongly recommended that you configure the app to seek permission from the user for this action. For more details, check the Privacy section.

Remove the testing package from the final product. Although the Lumia SensorCore Testing package is a great tool to use while testing and debugging, it increases the size of your final product considerably, so it is recommended that you remove it before submitting your package to the store.

Features affecting the data quality

When the Lumia SensorCore SDK collects the sensor data, it relies on various features on the actual device to be available and turned on, such as location and motion data. Besides these features, there are certain features that will impact the quality of data depending on their availability; we illustrate these features in the following diagram.

Accelerometer

Cellular Network

GPS

WiFi

Step Counter

X

(*)

Activity Monito

X

(*)

Place Monitor

X*

X

X*

Track Point Monitor

X*

X

X*

* Will also improve the GPS performance if present
(*) If motion data is set to Detailed mode

Note:

  • Accelerometer is crucial for the functionality of Step Counter and Activity Monitor.
  • It is good to notice that Accuracy of Track Point Monitor is area dependent if motion data is set to Basic. The accuracy is optimal in densely populated regions with plenty of cell towers and Wi-Fi base stations.
Show: