Data | StepDiary

The SDK’s Health Data provides a 'StepDiary' sample application to read the daily step count. Check the sample application by importing its project with Android Studio (or Eclipse).

Prerequisites

Prerequisites to run StepDiary are:

  • Prepare an Android device that supports Android 4.4KitKat (API level 19) or above.(Samsung and non-Samsung devices are available both.)

  • Install the latest Samsung Health.

  • Turn on the developer mode.

  • Import StepDiary with Android Studio (or Eclipse).

  • Run StepDiary on the device.

Overview

StepDiary demonstrates how to use Health Data’s APIs for retrieving the daily step count with HealthConstants.StepCount and daily step count trend data types.

It shows how to handle the step’s binning data every 10 minutes.

Figure 17 shows its screenshots.

Figure 17: StepDiary sample app

Table 9 describes source and resource files of StepDiary.

Source / Resource Description
AndroidManifest.xml Declaring required permissions with the <meta-data> element.
src/com/samsung/android/stepdiary
MainActivity.java

StepDiary's main activity

  • Connecting to the health data store and handling exceptions through ConnectionListener.
  • Checking permission to read HealthConstants.StepCount and daily step count trend.
  • Requesting permission if required.
  • Creating an option menu for setting permission.
  • Showing daily step count.
StepCountReporter.java
  • Reading today’s step count with HealthConstants.StepCount asynchronously.
    It checks the total step count and binning data every 10 minutes.
  • Reading daily step count before today with the daily step count trend asynchronously.
    It checks the total step count and binning data every 10 minutes.
Table 9: StepDiary’s source description

See detailed implementation in the imported StepDiary’s project through Android Studio (or Eclipse).