Service | PluginTracker

Health Service provides a sample application 'PluginTracker' to show how to post your tracker tile and work with Samsung Health. Check the sample application by importing its project with Android Studio (or Eclipse).


Prerequisites to run PluginTracker are shown below.

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

  • Install Samsung Health on the device.

  • Turn on the developer mode as 4.3.1.

  • Import PluginTracker with Android Studio (or Eclipse).

  • Run PluginTracker on the device.


If Samsung Health and PluginTracker are installed properly, you can:

  • Find the Sample tracker on the Samsung Health‘s tracker list after installing the sample app.

  • Launch some Samsung Health's available tracker.

Figure 15: PluginTracker Figure 15: PluginTracker

If you subscribe to the Sample tracker and go back to the Samsung Health‘s main screen, its tile will be shown as the middle figure. Its tile is posted with TRACKER_TILE_TYPE_1 at the first time. The sample app's posted tile will be changed to the different tile template - TRACKER_TILE_TYPE_3 that includes a content value, unit, and updated time whenever the tile's button is tapped.

The posted tracker tile's ID can be checked on PluginTracker as the Figure 15's third screenshot and you can remove the posted tracker tile.

Connection to Health Data Store

The app needs to use the SDK's Health Data basically and connect to the health data store to handle various exceptions whether the app can work with Samsung Health on the device.

But PluginTracker doesn't include the Health Data API usage because it focuses to show the tracker usage only.

See the SimpleHealth sample application in the SDK or the Health Data‘s Programming Guide for the health data store connection.

Source Description

Table 6 describes source and resource files of PluginTracker.

Source / Resource Description
  • Registering the tracker tile button's service intent (MyTrackerService) with the <service> element.

  • Declaring Samsung Health's PluginService with the <service> element.

Testtracker.xml Defining tracker with its metadata.
src/com/samsung/android/app/plugintracker/ PluginTracker's main activity.
  • TrackerManager

    • Showing a list for some Samsung Health trackers.

    • Launching the selected tracker.

  • TrackerTileManager

    • Showing the posted tile's ID on the Samsung Health's main screen.

    • Containing a button to remove a posted tile. Checking the feature availability.
Implementing the app's tracker.
  • Implementing TrackerEventListener to receive the following tracker events from Samsung Health:

    • If the user subscribes or unsubscribes the PluginTracker's tracker,
      => onSubscribed(), onUnsubscribed()

    • If Samsung Health goes to the background,
      => onPaused()

    • If Samsung Health requests the tracker tile of PluginTracker,
      => onTileRequested()

    • If the posted tile is removed from the Samsung Health's main screen,
      => onTileRemoved()

  • Posting or updating the tracker tile of PluginTracker depending on the received tracker event. Initializing the Health Service.
MyTrackerService Defining the tracker tile's button intent to be performed in the background.
Table 6: PluginTracker's source description

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