Data | FoodNote

FoodNote sample download | Apr 11, 2019
(Nov 3, 2020)

The SDK's Health Data provides a FoodNote sample application to show how to manage nutrition data with Samsung Health after the permission request.

Prerequisites

Prerequisites to run FoodNote are:

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

  • Add the FoodNote app's dev access code developer mode.

    • Client ID: com.samsung.android.app.foodnote
    • Access code: Qeca0ZBM
  • Import FoodNote with Android Studio (or Eclipse).

  • Run FoodNote on the device.

Overview

FoodNote demonstrates how to use Health Data's APIs for checking the selected day's food intake with HealthConstants.Nutrition including permission request.

Especially, the health data store connection and exception handling would be helpful to your application to prepare unexpected error.

FoodNote's sources and resources are:

Source / Resource

Description

AndroidManifest.xml

Declaring required permissions with the <meta-data> element.

java/com/samsung/android/app/foodnote

 

AppConstants.java

Getting the meal type name.

ChooseFoodActivity.java

Loading the food list of the FoodInfoTable class and showing them that the user can choose.

FoodDataHelper.java

  • Inserting nutrition data.
  • Deleting nutrition data.
  • Reading nutrition data of the selected day and the meal type.
FoodInfoTable.java

Defining sample food information.

MainActivity.java

FoodNote's main activity.
  • Connecting to the health data store and handling exceptions through ConnectionListener.
  • Checking permission for HealthConstants.Nutrition and requesting permission if required.
  • Creating an option menu for setting permission.
  • Showing the selected day's calorie intake.
  • Adding an observer to get notification for the calorie change.

MealStoreActivity.java

  • Showing a list of food intake items for the selected meal that is chosen on MainActivity.
  • Deleting a food intake item in the list.