Subscribe to daily Health Data using Huawei Health

DataReportModel modelCaloriesInterval = new DataReportModel(HiHealthPointType.DATA_POINT_CALORIES_SUM,
CharacteristicConstant.ReportType.VALUE_INTERVAL.getReportTypeValue(), 300);

// Result callback.
HiRealTimeCallback hiRealTimeCallback = new HiRealTimeCallback() {
public void onResult(int errCode, String message) {
if (errCode == HiHealthError.SUCCESS) {
Log.i(TAG, “success”);

public void onDataChanged(Bundle bundle) {
// Notify the subscriber when the total calories burned reach 30 kcal (the actual calories burned will be returned).
Log.i(TAG, String.valueOf(bundle.getInt(HiHealthKitConstant.BUNDLE_KEY_CALORIE)));

// Subscribe to calories.
HiHealthDataStore.registerDataAutoReport(context, modelCaloriesInterval, hiRealTimeCallback);

// Cancel the subscription.
HiHealthDataStore.unregisterDataAutoReport(context, modelCaloriesInterval, hiRealTimeCallback);



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store