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.
Manage Your Cookies
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
developer.samsung.com, .samsung.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
Samsung Electronics
.samsung.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
Samsung Electronics
developer.samsung.com, google.account.samsung.com
Preferences Submitted
You have successfully updated your cookie preferences.