-
@ExperimentalCoroutinesApi() public final class SHealthManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
SHealthManager.Companion
public interface
SHealthManager.SHealthListener
An interface for receiving events from SHealth.
public interface
SHealthManager.SHealthObserverListener
-
Field Summary
Fields Modifier and Type Field Description private SHealthManager.SHealthListener
sHealthListener
private SHealthManager.SHealthObserverListener
observerListener
private final Set<String>
currentSubscriptions
private NotificationParams
notificationParams
-
Method Summary
Modifier and Type Method Description final SHealthManager.SHealthListener
getSHealthListener()
Register to receive events from SHealth. final Unit
setSHealthListener(SHealthManager.SHealthListener sHealthListener)
Register to receive events from SHealth. final SHealthManager.SHealthObserverListener
getObserverListener()
Register an observer for when subscriptions start and stop potentially due to the OS managing resources. final Unit
setObserverListener(SHealthManager.SHealthObserverListener observerListener)
Register an observer for when subscriptions start and stop potentially due to the OS managing resources. final Set<String>
getCurrentSubscriptions()
final NotificationParams
getNotificationParams()
final Unit
setNotificationParams(NotificationParams notificationParams)
final Map<String, Boolean>
hasReadAccess(Set<String> dataTypes)
Check if access has been previously granted by an end user for Read access to data types final Unit
requestPermissions(Set<String> permissions, Activity activity)
Requests permissions for specific data types from Samsung Health. final Unit
requestPermissions(Set<String> permissions)
Requests permissions for specific data types from Samsung Health. final Unit
requestSHealthSubscriptions(Iterable<SHealthSubscription> subscriptions)
Request subscriptions for specific Samsung Health data types with a foreground service. final Unit
requestSubscriptions(Iterable<String> subscriptions)
Request subscriptions for specific Samsung Health data types with a foreground service. final Unit
removeSHealthSubscriptions(Iterable<SHealthSubscription> subscriptions)
Stop listening for SHealth data on the given subscriptions. final Unit
removeSubscriptions(Iterable<String> subscriptions)
Stop listening for SHealth data on the given subscriptions. final Unit
removeAllSubscriptions()
Stop listening for any S Health data. final Unit
observeCurrentSubscriptions(NotificationParams params)
Resume the SHealth service. final Unit
observeCurrentSubscriptions()
Resume the SHealth service. final Unit
fetchHistoricalSets(Iterable<SHealthSubscription.SHealthHistoricalSet> dataTypes, LocalDate from, LocalDate to)
Fetch historical data (6 months) for a set of SHealthSubscription.SHealthHistoricalSet. final Unit
fetchHistoricalSets(Iterable<SHealthSubscription.SHealthHistoricalSet> dataTypes, LocalDate from)
Fetch historical data (6 months) for a set of SHealthSubscription.SHealthHistoricalSet. final Unit
fetchHistoricalSets(Iterable<SHealthSubscription.SHealthHistoricalSet> dataTypes)
Fetch historical data (6 months) for a set of SHealthSubscription.SHealthHistoricalSet. final Unit
fetchHistoricalSets(Iterable<SHealthSubscription.SHealthHistoricalSet> dataTypes, Calendar from, Calendar to)
Fetch historical data (6 months) for a set of SHealthSubscription.SHealthHistoricalSet. -
-
Method Detail
-
getSHealthListener
final SHealthManager.SHealthListener getSHealthListener()
Register to receive events from SHealth. The listener is managed using a weak reference so it is important to keep a reference to your listener.
-
setSHealthListener
final Unit setSHealthListener(SHealthManager.SHealthListener sHealthListener)
Register to receive events from SHealth. The listener is managed using a weak reference so it is important to keep a reference to your listener.
-
getObserverListener
final SHealthManager.SHealthObserverListener getObserverListener()
Register an observer for when subscriptions start and stop potentially due to the OS managing resources. The listener is managed using a weak reference so it is important to keep a reference to your listener.
-
setObserverListener
final Unit setObserverListener(SHealthManager.SHealthObserverListener observerListener)
Register an observer for when subscriptions start and stop potentially due to the OS managing resources. The listener is managed using a weak reference so it is important to keep a reference to your listener.
-
getCurrentSubscriptions
final Set<String> getCurrentSubscriptions()
-
getNotificationParams
final NotificationParams getNotificationParams()
-
setNotificationParams
final Unit setNotificationParams(NotificationParams notificationParams)
-
hasReadAccess
final Map<String, Boolean> hasReadAccess(Set<String> dataTypes)
Check if access has been previously granted by an end user for Read access to data types
-
requestPermissions
@JvmOverloads() final Unit requestPermissions(Set<String> permissions, Activity activity)
Requests permissions for specific data types from Samsung Health. The user will be prompted to accept permissions immediately after calling this. SHealthListener.onPermissionChange will be called with the results. Note that no subscriptions or further action will be performed along with the request of permissions.
- Parameters:
permissions
- The set of permissions to request.
-
requestPermissions
@JvmOverloads() final Unit requestPermissions(Set<String> permissions)
Requests permissions for specific data types from Samsung Health. The user will be prompted to accept permissions immediately after calling this. SHealthListener.onPermissionChange will be called with the results. Note that no subscriptions or further action will be performed along with the request of permissions.
- Parameters:
permissions
- The set of permissions to request.
-
requestSHealthSubscriptions
final Unit requestSHealthSubscriptions(Iterable<SHealthSubscription> subscriptions)
Request subscriptions for specific Samsung Health data types with a foreground service. This method assumes that permissions have already been requested and granted for each subscription. Please call SHealthManager.requestPermissions to obtain permissions before using this method.
- Parameters:
subscriptions
- The subscriptions to request.
-
requestSubscriptions
final Unit requestSubscriptions(Iterable<String> subscriptions)
Request subscriptions for specific Samsung Health data types with a foreground service. This method assumes that permissions have already been requested and granted for each subscription. Please call SHealthManager.requestPermissions to obtain permissions before using this method.
- Parameters:
subscriptions
- The subscriptions to request.
-
removeSHealthSubscriptions
final Unit removeSHealthSubscriptions(Iterable<SHealthSubscription> subscriptions)
Stop listening for SHealth data on the given subscriptions.
-
removeSubscriptions
final Unit removeSubscriptions(Iterable<String> subscriptions)
Stop listening for SHealth data on the given subscriptions.
-
removeAllSubscriptions
final Unit removeAllSubscriptions()
Stop listening for any S Health data.
-
observeCurrentSubscriptions
@JvmOverloads() final Unit observeCurrentSubscriptions(NotificationParams params)
Resume the SHealth service.
-
observeCurrentSubscriptions
@JvmOverloads() final Unit observeCurrentSubscriptions()
Resume the SHealth service.
-
fetchHistoricalSets
@JvmOverloads() final Unit fetchHistoricalSets(Iterable<SHealthSubscription.SHealthHistoricalSet> dataTypes, LocalDate from, LocalDate to)
Fetch historical data (6 months) for a set of SHealthSubscription.SHealthHistoricalSet. If an SHealthListener is registered with the manager, records created or updated in Shealth will call SHealthListener.onRecords. If a data type is not valid SHealthListener.onError will be called with SHealthError.INVALID_DATA_TYPE.
- Parameters:
dataTypes
-An array of SHealthSubscription.SHealthHistoricalSet representing the Samsung Health data types.
-
fetchHistoricalSets
@JvmOverloads() final Unit fetchHistoricalSets(Iterable<SHealthSubscription.SHealthHistoricalSet> dataTypes, LocalDate from)
Fetch historical data (6 months) for a set of SHealthSubscription.SHealthHistoricalSet. If an SHealthListener is registered with the manager, records created or updated in Shealth will call SHealthListener.onRecords. If a data type is not valid SHealthListener.onError will be called with SHealthError.INVALID_DATA_TYPE.
- Parameters:
dataTypes
-An array of SHealthSubscription.SHealthHistoricalSet representing the Samsung Health data types.
-
fetchHistoricalSets
@JvmOverloads() final Unit fetchHistoricalSets(Iterable<SHealthSubscription.SHealthHistoricalSet> dataTypes)
Fetch historical data (6 months) for a set of SHealthSubscription.SHealthHistoricalSet. If an SHealthListener is registered with the manager, records created or updated in Shealth will call SHealthListener.onRecords. If a data type is not valid SHealthListener.onError will be called with SHealthError.INVALID_DATA_TYPE.
- Parameters:
dataTypes
-An array of SHealthSubscription.SHealthHistoricalSet representing the Samsung Health data types.
-
fetchHistoricalSets
final Unit fetchHistoricalSets(Iterable<SHealthSubscription.SHealthHistoricalSet> dataTypes, Calendar from, Calendar to)
Fetch historical data (6 months) for a set of SHealthSubscription.SHealthHistoricalSet. If an SHealthListener is registered with the manager, records created or updated in Shealth will call SHealthListener.onRecords. If a data type is not valid SHealthListener.onError will be called with SHealthError.INVALID_DATA_TYPE.
- Parameters:
dataTypes
-An array of SHealthSubscription.SHealthHistoricalSet representing the Samsung Health data types.
from
-The Calendar date representing the ending time instant of the fetch query.
to
-The Calendar date representing the starting time instant of the fetch query.
-
-
-
-