The SDK’s Health Data provides a 'SimpleHealth' sample application to read the today’s step count. Check the sample application by importing its project with Android Studio (or Eclipse).
Prerequisites to run SimpleHealth are:
Prepare an Android device that supports Android 4.4KitKat (API level 19) or above.
(Samsung and non-Samsung devices are available both).
Install latest Samsung Health.
Turn on the developer mode.
Import SimpleHealth with Android Studio (or Eclipse).
Run SimpleHealth on the device.
SimpleHealth demonstrates how to use Health Data’s APIs for retrieving the today’s step count with HealthConstants. StepCount data type and HealthDataObserver.
Especially, the health data store connection and exception handling would be helpful to your application to prepare unexpected error.
The following table describes source and resource files of SimpleHealth.
Source / Resource | Description |
---|---|
AndroidManifest.xml | Declaring required permissions with the <meta-data> element. |
src/com/samsung/android/simplehealth | |
MainActivity.java | SimpleHealth’s main activity.
|
StepCountReporter.java |
|
See detailed implementation in the imported SimpleHealth’s project through Android Studio (or Eclipse).