com.samsung.android.sdk.healthdata
Class HealthDataResolver.ReadRequest.Builder
- java.lang.Object
-
- com.samsung.android.sdk.healthdata.HealthDataResolver.ReadRequest.Builder
-
- Enclosing interface:
- HealthDataResolver.ReadRequest
public static class HealthDataResolver.ReadRequest.Builder extends Object
This class is a builder to configureHealthDataResolver.ReadRequest
.private HealthDataResolver.ReadRequest buildReadRequest(long startTime, long endTime) { HealthDataResolver.Filter filter = HealthDataResolver.Filter.greaterThan(HealthConstants.Nutrition.CALORIE, 200); HealthDataResolver.ReadRequest request = new HealthDataResolver.ReadRequest.Builder() .setDataType(HealthConstants.Nutrition.HEALTH_DATA_TYPE) .setLocalTimeRange(HealthConstants.Nutrition.START_TIME, HealthConstants.Nutrition.TIME_OFFSET, startTime, endTime) .setFilter(filter) .build(); return request; }
- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor and Description Builder()
Helps to construct aHealthDataResolver.ReadRequest
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description HealthDataResolver.ReadRequest
build()
Builds a newHealthDataResolver.ReadRequest
object.HealthDataResolver.ReadRequest.Builder
setDataType(String type)
Sets a health data type for the request to read.HealthDataResolver.ReadRequest.Builder
setFilter(HealthDataResolver.Filter filter)
Sets a filter for the request to read.HealthDataResolver.ReadRequest.Builder
setLocalTimeRange(String timeProperty, String offsetProperty, long begin, long end)
Sets the local time range not to miss data from the query's result when there exist data with a differentTIME_OFFSET
in the saved health data.HealthDataResolver.ReadRequest.Builder
setPackageName(String packageName)
Sets the package name that provides health data to read.HealthDataResolver.ReadRequest.Builder
setProperties(String[] properties)
Sets a property array for the health data result to read.HealthDataResolver.ReadRequest.Builder
setPropertyAlias(String property, String alias)
Sets an alias for the given property.HealthDataResolver.ReadRequest.Builder
setResultCount(int offset, int count)
Sets the count range of result data with a given offset and count.HealthDataResolver.ReadRequest.Builder
setSort(String property, HealthDataResolver.SortOrder sortOrder)
Sets the sort order for a given property or alias.HealthDataResolver.ReadRequest.Builder
setSourceDevices(List<String> uuidList)
Sets a UUID list for source devices to read health data.HealthDataResolver.ReadRequest.Builder
setTimeAfter(long time)
Sets the time range to retrieve result data which is inserted or updated to the health data store after the given time.
-
-
-
Constructor Detail
-
Builder
public Builder()
Helps to construct aHealthDataResolver.ReadRequest
object.- Since:
- 1.0.0
-
-
Method Detail
-
setDataType
public HealthDataResolver.ReadRequest.Builder setDataType(String type)
Sets a health data type for the request to read. It has to be specified before callingbuild()
.- Parameters:
type
-HEALTH_DATA_TYPE
of the data type- Returns:
- The object that applies the health data type
- Since:
- 1.0.0
-
setFilter
public HealthDataResolver.ReadRequest.Builder setFilter(HealthDataResolver.Filter filter)
Sets a filter for the request to read.- Parameters:
filter
- The filter object- Returns:
- The object that applies the
filter
- Since:
- 1.0.0
-
setSourceDevices
public HealthDataResolver.ReadRequest.Builder setSourceDevices(List<String> uuidList)
Sets a UUID list for source devices to read health data.- Parameters:
uuidList
- The UUID list for source devices- Returns:
- The object that applies source devices
- Since:
- 1.0.0
-
setProperties
public HealthDataResolver.ReadRequest.Builder setProperties(String[] properties)
Sets a property array for the health data result to read. If it is not specified, the health data result shows all properties of the data type.- Parameters:
properties
- Properties that want to gain in the result- Returns:
- The object that applies
properties
- Since:
- 1.0.0
-
setPropertyAlias
public HealthDataResolver.ReadRequest.Builder setPropertyAlias(String property, String alias)
Sets an alias for the given property.- Parameters:
property
- The property to be shown with thealias
alias
- The alias for theproperty
- Returns:
- The object that applies the alias for the property
- Since:
- 1.0.0
-
setPackageName
public HealthDataResolver.ReadRequest.Builder setPackageName(String packageName)
Sets the package name that provides health data to read.Accessory Data's Package Name
Samsung Health collects the linked accessory's data also like Galaxy Watch.
The accessory's data including Galaxy Watch is inserted to Samsung Health with the Samsung Health's package name,com.sec.android.app.shealth
.
If you want to read only the specific accessory's data, make a division the device ID.- Parameters:
packageName
- The package name that provides health data- Returns:
- The object that applies the package name
- Since:
- 1.0.0
-
setSort
public HealthDataResolver.ReadRequest.Builder setSort(String property, HealthDataResolver.SortOrder sortOrder)
Sets the sort order for a given property or alias.- Parameters:
property
- The property or alias to be shown with the sort ordersortOrder
- The sort order- Returns:
- The object that applies the sort order
- Since:
- 1.0.0
-
setResultCount
public HealthDataResolver.ReadRequest.Builder setResultCount(int offset, int count)
Sets the count range of result data with a given offset and count. If this method is not called, all result will be obtained from the result.If you want to get only 10 data from the 3rd position in the result, set
offset
as 2 andcount
as 10.- Parameters:
offset
- The start position in the whole result, which equals to or is greater than 0count
- The limited count of result, which is greater than 0- Returns:
- The object that applies the range of the result
- Since:
- 1.0.0
-
setTimeAfter
public HealthDataResolver.ReadRequest.Builder setTimeAfter(long time)
Sets the time range to retrieve result data which is inserted or updated to the health data store after the given time.
It's different to set the time range based on the data's created or updated time to read data. If then, use:- If the data's source device is same with the current device,
time
means the inserted time that data is created on the current device. - If the data's source device is different,
time
indicates the synchronized time that data on other devices is synchronized to Samsung Health of the current device.
- Parameters:
time
- The time range to retrieve result data which is inserted or updated to the health data store after the specific time in milliseconds. Its value is started from January, 1, 1970 00:00:00 UTC.- Returns:
- The object that applies the range of the result
- Since:
- 1.0.0
- If the data's source device is same with the current device,
-
setLocalTimeRange
public HealthDataResolver.ReadRequest.Builder setLocalTimeRange(String timeProperty, String offsetProperty, long begin, long end)
Sets the local time range not to miss data from the query's result when there exist data with a differentTIME_OFFSET
in the saved health data.
The data that has a different
TIME_OFFSET
with other data'sTIME_OFFSET
can be saved when the daylight time is applied or the user moves to another region by like a travel. Building a complete query to read all data including the differentTIME_OFFSET
is not easy.
Use this API to build a read request as possible.- Parameters:
timeProperty
- The time property name that needs to add a filteroffsetProperty
- The time offset propertybegin
- The beginning time withGMT+0
milliseconds.
E.g. If you would like to get data from00:00:00
on October 26th, 2021 in your region, set the value with1635206400000
.
See sample codes.
Its minimum value isLong.MIN_VALUE
.end
- The end time withGMT+0
milliseconds.
E.g. If you would like to get data until00:00:00
on October 26th, 2021 in your region, set the value with1635206400000
.
See sample codes.
Its maximum value isLong.MAX_VALUE
.- Returns:
- The object that applies the local time range
- Since:
- 1.3.0
-
build
public HealthDataResolver.ReadRequest build()
Builds a newHealthDataResolver.ReadRequest
object. Check if following information is specified.- Data type
- Returns:
- The
HealthDataResolver.ReadRequest
object - Throws:
IllegalStateException
- If enough information is not specified- Since:
- 1.0.0
- See Also:
setDataType(String)
-
-