Interface HealthConstants.StepDailyTrend
-
- All Superinterfaces:
- HealthConstants.Common
- Enclosing class:
- HealthConstants
public static interface HealthConstants.StepDailyTrend extends HealthConstants.Common
This interface defines the user's daily step count trend data.Getting All Steps
The daily step count trend gives summarized step count data in a day.
It's a common case that the user has a phone and an accessory like a Galaxy Watch.
Sometimes the user can carry the phone and the accessory both. Or he/she can carry only one device for other times.HealthConstants.StepCount
in Samsung Health.Reading
HealthConstants.StepCount
of 1) and 4) sessions will give more step count than the user's real steps. Because the query's result includes duplicated steps of 'Phone' and 'Watch'. But removing duplications is not easy with a manual handling.HealthConstants.StepDailyTrend
provides a simple way to get the user's all steps without duplications. Just set a filter forSOURCE_TYPE
withSOURCE_TYPE_ALL
with a reading query.// State of connection private HealthDataStore mStore; // Resolver instance private final HealthDataResolver mResolver; public static long getTodayStartUtcTime() { Calendar today = Calendar.getInstance(TimeZone.getTimeZone("UTC")); today.set(Calendar.HOUR_OF_DAY, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); return today.getTimeInMillis(); } public void readTodayStepCountData() { // Suppose that the required permission has been acquired already // Create a filter for today's steps from all source devices Filter filter = Filter.and( Filter.eq(StepDailyTrend.DAY_TIME, getTodayStartUtcTime()), Filter.eq(StepDailyTrend.SOURCE_TYPE, StepDailyTrend.SOURCE_TYPE_ALL)); ReadRequest request = new ReadRequest.Builder() // Set the data type .setDataType(StepDailyTrend.HEALTH_DATA_TYPE) // Set a filter .setFilter(filter) // Build .build(); mResolver = new HealthDataResolver(store, null); try { mResolver.read(request).setResultListener(result -> { long dayTime = 0; int totalCount = 0; try { Iterator iterator = result.iterator(); if (iterator.hasNext()) { HealthData data = iterator.next(); dayTime = data.getLong(StepDailyTrend.DAY_TIME) totalCount = data.getInt(StepDailyTrend.COUNT); } } finally { result.close(); } }); } catch (Exception e) { Log.e(MainActivity.APP_TAG, e.getClass().getName() + " - " + e.getMessage()); } }
StepDailyTrend Data's Creation and Update
The user's steps are collected through a phone or connected accessories like a watch.
StepDailyTrend
data is created after the user's steps are detected. The createdStepDailyTrend
data is updated every minutes (usually one minute) if a step count is changed.A number of
StepDailyTrend
data is one for eachSOURCE_TYPE
in a day if the source type collects steps. EspeciallySOURCE_TYPE_ALL
data exists always if otherSOURCE_TYPE
data is created.Properties
Properties of the following extending interfaces are available for this data type.
Step daily trend data has the following properties.
See more common properties by spreading this section out.Property name Description HealthConstants.StepDailyTrend.DEVICE_UUID [Mandatory]
Device identifier which provides the health dataHealthConstants.StepDailyTrend.DAY_TIME [Mandatory]
The date of summarized step count data in milliseconds. It indicates00:00:00
UTC of the date exactly,HealthConstants.StepDailyTrend.COUNT [Mandatory]
Total number of daily stepsHealthConstants.StepDailyTrend.BINNING_DATA Gathering data of the daily step count for every 10 minutes with the JSON format HealthConstants.StepDailyTrend.CALORIE Total burned calories for daily steps in kilocalories HealthConstants.StepDailyTrend.DISTANCE Total distance for daily steps in meters HealthConstants.StepDailyTrend.SOURCE_PKG_NAME Package name that provides step count data HealthConstants.StepDailyTrend.SOURCE_TYPE Kind of devices HealthConstants.StepDailyTrend.SPEED Average speed of daily steps in meters per second. Data Permission
The user's consent is required to read or write this data type. HealthPermissionManager.requestPermissions() displays a data permission UI to the user.
See Permission Manager and request data permission.- Since:
- 1.5.0
-
-
Field Summary
Fields Modifier and Type Field and Description static String
BINNING_DATA
A set of step count data for every 10 minutes with the JSON format.static String
CALORIE
Total burned calories for daily steps in kilocalories.static String
COUNT
Total number of daily steps.static String
DAY_TIME
The date of summarized step count data in milliseconds.static String
DISTANCE
Total distance for daily steps in meters.static String
HEALTH_DATA_TYPE
Data type name for step daily trend data.static String
SOURCE_PKG_NAME
Package name that provides step count data.static String
SOURCE_TYPE
Kind of data sources like a connected accessory device.static int
SOURCE_TYPE_ALL
All data sources, including: Partner apps only Local device (phone) Connected accessory devices like Galaxy Watch or activity trackers Samsung Health creates oneStepDailyTrend
data record for eachSOURCE_TYPE
everyday.static int
SOURCE_TYPE_PARTNER_APP
Each partner app.static int
SOURCE_TYPE_PHONE_ONLY
Phone only.static String
SPEED
Average speed of daily steps in meters per second.-
Fields inherited from interface com.samsung.android.sdk.healthdata.HealthConstants.Common
CREATE_TIME, CUSTOM, DEVICE_UUID, PACKAGE_NAME, UPDATE_TIME, UUID
-
-
-
-
Field Detail
-
DAY_TIME
static final String DAY_TIME
The date of summarized step count data in milliseconds. It indicates00:00:00
UTC of the date exactly.- Mandatory
- Type:
long
- Since:
- 1.5.0
- See Also:
- Constant Field Values
-
COUNT
static final String COUNT
Total number of daily steps.- Mandatory
- Type:
int
- Since:
- 1.5.0
- See Also:
- Constant Field Values
-
BINNING_DATA
static final String BINNING_DATA
A set of step count data for every 10 minutes with the JSON format.
It provides maximum 144 data, 6 in an hour * 24 hours.
COUNT
gives just a total step count. You can use this info to track more detailed step activity.- Optional
- Type:
byte[]
JSON key Type "count" int
"calorie" float
"distance" float
"speed" float
When you request to read daily step count data, Samsung Health gives the result as compressed ZIP that contains 144 (one day = 10 minutes * 6 * 24 hours) JSON formatted data with the time order. You can estimate each data's time information by counting the data's order. The following example shows one of JSON formatted data.
{ "count":75 "calorie":4.0864094495773315, "distance":56.0, "speed":0.001272727269679308 }
Its use cases are:
- Since:
- 1.5.0
- See Also:
HealthDataUtil
, Constant Field Values
-
CALORIE
static final String CALORIE
Total burned calories for daily steps in kilocalories.- Optional
- Type:
float
- Since:
- 1.5.0
- See Also:
- Constant Field Values
-
DISTANCE
static final String DISTANCE
Total distance for daily steps in meters.- Optional
- Type:
float
- Since:
- 1.5.0
- See Also:
- Constant Field Values
-
SOURCE_PKG_NAME
static final String SOURCE_PKG_NAME
Package name that provides step count data.
IfSOURCE_TYPE
isSOURCE_TYPE_ALL
orSOURCE_TYPE_PHONE_ONLY
, this value iscom.sec.android.app.shealth
.
- Optional
- Type:
String
- Since:
- 1.5.0
- See Also:
- Constant Field Values
-
SOURCE_TYPE
static final String SOURCE_TYPE
Kind of data sources like a connected accessory device.
It differs withHealthConstants.Common.DEVICE_UUID
that indicates data's each source device.- Optional
- Type:
int
- Available values: one of the following values
- Since:
- 1.5.0
- See Also:
- Constant Field Values
-
SOURCE_TYPE_ALL
static final int SOURCE_TYPE_ALL
All data sources, including:- Partner apps only
- Local device (phone)
- Connected accessory devices like Galaxy Watch or activity trackers
StepDailyTrend
data record for eachSOURCE_TYPE
everyday. Samsung Health checks steps for each source device continuously and updates the data records before the next day's00:00:00
. If there is no step forSTEP_SOURCE_TYPE
, its data record is not created.Created data is updated every minutes whenever steps are changed in a day including data for
SOURCE_TYPE_ALL
.- Since:
- 1.5.0
- See Also:
SOURCE_TYPE
, Constant Field Values
-
SOURCE_TYPE_PARTNER_APP
static final int SOURCE_TYPE_PARTNER_APP
Each partner app.
This source type data is created at the end of every day about00:00:00
UTC if a partner app's step count exists in a day. It doesn't provide today's data but until yesterday. UseHealthConstants.StepCount
for today's phone step data.
SeeSOURCE_PKG_NAME
to find an wanted partner app.- Since:
- 1.5.0
- See Also:
SOURCE_TYPE
, Constant Field Values
-
SOURCE_TYPE_PHONE_ONLY
static final int SOURCE_TYPE_PHONE_ONLY
Phone only.
This source type data is created at the end of every day about00:00:00
UTC if the phone's step count exists in a day. It doesn't provide today's data but until yesterday. UseHealthConstants.StepCount
for today's phone step data.- Since:
- 1.5.0
- See Also:
SOURCE_TYPE
, Constant Field Values
-
SPEED
static final String SPEED
Average speed of daily steps in meters per second.- Optional
- Type:
float
- Since:
- 1.5.0
- See Also:
- Constant Field Values
-
HEALTH_DATA_TYPE
static final String HEALTH_DATA_TYPE
Data type name for step daily trend data.
Use"com.samsung.shealth.step_daily_trend"
to add permission to the manifest file.- Since:
- 1.5.0
- See Also:
- Constant Field Values
-
-