Use SmartBand 2 sensor data for Android and iOS apps
As an app developer, you can retrieve sensor data from SmartBand 2 using standard sets of APIs for Android and iOS platforms. You can then analyze and process the sensor data to provide useful insights and visualizations that can help your users live a healthier lifestyle.
SmartBand 2 is compatible with any smartphone running at least Android 4.4 or iOS 8.2, and it’s equipped with an accelerometer and a heart rate monitor. It tracks steps and activities like walking, running, and sleeping, while also monitoring heart rate (HR) and heart rate variability (HRV). This way, the SmartBand 2 will provide data allowing for biometric tracking and insights into overall fitness, excitement, stress and recovery levels throughout the day and night.
In the following sections you will find information about the different sets of APIs that can be used to collect sensor data from SmartBand:
Use Google Fit APIs to store and access fitness data from any wearable and sensor
Google Fit is an open ecosystem that allows developers to upload and store sensor data to a central cloud based repository. If your users grant you permission, you can access their data using the Google Fit APIs.
The Google Fit APIs consist of two sets of APIs:
- Google Fit Android APIs included in Google Play services, for Android apps.
- Google Fit REST API, for apps on any platform.
Both sets of the Google Fit APIs work with three types of data: Public data types, Custom data types, and Shareable data types. SmartBand 2 provides the following Public data types to the Google Fitness Store:
- google.step_count.delta (steps)
- google.heart_rate.bpm (heart rate in bpm)
- google.activity.segment (sleeping, walking, running)
Using the Google Fit REST API, you first make an API call to get a list of available data sources (you might have several):
The data sources contain data sets which hold the activity data you are interested in, for instance where the data type is com.google.step_count.delta (steps) and the source is com.sonymobile.hostapp.everest (SmartBand 2). The API call for getting data sets is:
|dataSourceId||string||The format of the dataSourceId created by an Android application is: type:dataType.name:application.packageName:device.manufacturer:device.model:device.uid:dataStreamName|
|datasetId||string||The datasetId is formatted like “startTime-endTime”, where startTime and endTime are 64 bit integers.|
Based on this, the call to retrieve step count data from For SmartBand 2 would look like this:
To learn more about Google Fit, and get started using the Google Fit APIs, visit the Gooogle Fit platform overview.
Use HealthKit to manage, use and share fitness data on devices running iOS
The HealthKit framework is designed to let apps use and share fitness data from a wide range of sources and sensors. All collected data are stored locally in the HealthKit store on the user’s device, and can be accessed using HealthKit, the accompanying API included in the iOS SDK. The users can edit the permissions to read, write, and share, for each app and each data type.
HealthKit data is divided into two main groups: characteristics and samples. Characteristics data includes for example the user’s birth date and blood type – data that typically does not change. The Samples data can be partitioned into four types: Category samples, Quantity samples, Correlations, and Workouts.
SmartBand 2 provides Quantity and Category samples to the HealthKit store, which can be identified by:
- HKQuantityTypeIdentifierStepCount (steps)
- HKQuantityTypeIdentifierHeartRate (heart rate)
- HKCategoryTypeIdentifierSleepAnalysis (sleeping)
To query the HealthKit store for data, you call the initializer initWithSampleType:predicate:limit:sortDescriptors:resultsHandler:, and then run the query by calling the executeQuery: method.
Learn more about HealthKit by visiting The HealthKit Framework page.