原来的仓库只有healtKit,而没有 hihealthKit,不支持拓展能力的接口 android sdk 版本基于:6.3.0+301
- 1. Introduction
- 2. Installation Guide
- 3. API Reference
- 4. Configuration and Description
- 5. Sample Project
- 6. Questions or Issues
- 7. Licensing and Terms
HUAWEI Health Kit (Health Kit for short) allows ecosystem apps to access fitness and health data of users based on their HUAWEI ID and authorization. For consumers, Health Kit provides a mechanism for fitness and health data storage and sharing based on flexible authorization. For developers and partners, Health Kit provides a data platform and fitness and health open capabilities, so that they can build related apps and services based on a multitude of data types. Health Kit connects the hardware devices and ecosystem apps to provide consumers with health care, workout guidance, and ultimate service experience.
Before you get started, you must register as a HUAWEI Developer and complete identity verification on the HUAWEI Developer website. For details, please refer to Register a HUAWEI ID.
Creating an app in the AppGallery Connect is required in order to communicate with the Huawei services. To create an app, perform the following steps:
Step 1. Sign in to AppGallery Connect and select My projects.
Step 2. Select your project from the project list or create a new one by clicking the Add Project button.
Step 3. Go to Project Setting > General information, and click Add app. If an app exists in the project and you need to add a new one, expand the app selection area on the top of the page and click Add app.
Step 4. On the Add app page, enter the app information, and click OK.
A signing certificate fingerprint is used to verify the authenticity of an app when it attempts to access an HMS Core (APK) through the HMS SDK. Before using the HMS Core (APK), you must locally generate a signing certificate fingerprint and configure it in the AppGallery Connect. You can refer to 3rd and 4th steps of Generating a Signing Certificate codelab tutorial for the certificate generation. Perform the following steps after you have generated the certificate.
Step 1: Sign in to AppGallery Connect and select your project from My Projects. Then go to Project Setting > General information. In the App information field, click the add icon next to SHA-256 certificate fingerprint, and enter the obtained SHA-256 certificate fingerprint.
Step 2: After completing the configuration, click OK (Check mark icon) to save the changes.
HUAWEI Health Kit uses the HUAWEI ID Service in order the obtain the Health Kit permissions from the user. Head over to Huawei Developer Console and select the HUAWEI ID service from App Services under the Development Section. Click Apply for HUAWEI ID, agree to the agreement, and fill the information about your application for the required fields on the opened page. For details please visit Applying for the HUAWEI ID Service.
Note If the HUAWEI ID card can't be found, click Customize console in the upper right corner to add it.
In order to successfully activate the Health Kit Service for your application you need to complete the steps in the Applying for Health Kit document. After the Health Kit Service is authorized and enabled for your application on the Huawei Developer Console you can continue with the integration process.
Step 1: Sign in to AppGallery Connect and select your project from My Projects then navigate to Project Setting > General information page, under the App information field, click agconnect-services.json to download the configuration file.
Step 2: Copy the agconnect-services.json file to the android/app directory of your project.
Step 3: Open the build.gradle file in the android directory of your project.
-
Navigate to the buildscript section and configure the Maven repository address and agconnect plugin for the HMS SDK.
buildscript { repositories { google() jcenter() maven { url 'https://developer.huawei.com/repo/' } } dependencies { /* * <Other dependencies> */ classpath 'com.huawei.agconnect:agcp:1.4.2.301' } }
-
Go to allprojects and configure the Maven repository address for the HMS SDK.
allprojects { repositories { google() jcenter() maven { url 'https://developer.huawei.com/repo/' } } }
Step 5: Open the build.gradle file in the android/app/ directory.
-
Add
apply plugin: 'com.huawei.agconnect'
line after otherapply
entries.apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.huawei.agconnect'
-
Set your package name in defaultConfig > applicationId and set minSdkVersion to 21 or higher. Package name must match with the package_name entry in the agconnect-services.json file.
defaultConfig { applicationId "<package_name>" minSdkVersion 21 /* * <Other configurations> */ }
Step 6: Create a file <app_dir>/android/key.properties that contains a reference to your keystore which you generated on the previous step (Generating a Signing Certificate). Add the following lines to the key.properties file and change the values regarding to the keystore you've generated.
storePassword=<your_keystore_password>
keyPassword=<your_key_password>
keyAlias=<your_key_alias>
storeFile=<location of the keystore file, for example: D:\\Users\\<user_name>\\key.jks>
Warning: Keep this file private and don't include it on the public source control.
Step 7: Add the following code to the first line of android/app/build.gradle for reading the key.properties file:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
Step 8: Edit buildTypes as follows and add the signingConfigs below:
signingConfigs {
config {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
}
}
Step 9: On your Flutter project directory, find and open your pubspec.yaml file and add the huawei_health library to dependencies. For more details please refer to the Using packages document.
-
To download the package from pub.dev.
dependencies: huawei_health: {library version}
or
If you downloaded the package from the HUAWEI Developer website, specify the library path on your local device.
dependencies: huawei_health: # Replace {library path} with actual library path of Huawei Health Kit Plugin for Flutter. path: {library path}
- Replace {library path} with the actual library path of the Flutter Health Kit Plugin. The following are examples:
- Relative path example:
path: ../huawei_health
- Absolute path example:
path: D:\Projects\Libraries\huawei_health
- Relative path example:
- Replace {library path} with the actual library path of the Flutter Health Kit Plugin. The following are examples:
Step 10: Run the following command to update the package info.
[project_path]> flutter pub get
Step 11: Import the library to access the methods.
import 'package:huawei_health/huawei_health.dart';
Step 12: Run the following command to start the app.
[project_path]> flutter run
Detailed information about modules, classes and constants provided by this plugin is explained in this section. The summary is described in the table below.
Name | Description |
---|---|
Modules | Function classes that provide interaction with the HUAWEI Health Kit SDK methods. |
Option Classes | Request object classes for CRUD operations. |
Data Classes | Dataset classes for interacting with the data provided by Health Kit. |
Result Classes | Result classes for utilizing the Health Kit API results. |
Constants | Constants provided by the plugin. |
Huawei Health Kit Plugin for Flutter provides a set of function classes as described in the table below.
Name | Description |
---|---|
HealthAuth | Provides sign in method for obtaining the Health Kit Authorization from the user. |
ActivityRecordsController | Provides methods to create and manage user activity records. |
AutoRecorderController | Provides real-time data reading functions. |
DataController | Provides methods to add, delete, modify, and query the platform data. |
SettingController | Provides setting related functions. |
ConsentsController | Provides authorization management APIs that can be used to view and revoke the granted permissions. |
HMSLogger | Enable/Disable functions for the HMSLogger. |
Provides signIn method for obtaining the Health Kit Authorization from the user.
Method | Return Type | Description |
---|---|---|
signIn | Future<AuthHuaweiId> | Obtains the Health Kit permissions from the user by the defined List of Scopes. |
Obtains the Health Kit permissions from the user by the defined List of Scopes. The scopes that are asked to the user for authorization should already be authorized for the app on Huawei Developer Console. Please see the Applying for the Health Kit section.
Parameter | Type | Description |
---|---|---|
scopes | List<Scope> | List of Scopes to ask for authorization from the user. |
Type | Description |
---|---|
Future<AuthHuaweiId> | AuthHuaweiId object that contains the information about the user and granted Health Kit permissions. |
// List of scopes to ask for authorization.
//
// Note: These scopes should also be authorized on the Huawei Developer Console.
List<Scope> scopes = [
Scope.HEALTHKIT_HEIGHTWEIGHT_READ,
Scope.HEALTHKIT_HEIGHTWEIGHT_WRITE,
Scope.HEALTHKIT_ACTIVITY_WRITE,
Scope.HEALTHKIT_ACTIVITY_READ,
Scope.HEALTHKIT_ACTIVITY_RECORD_WRITE,
Scope.HEALTHKIT_ACTIVITY_RECORD_READ,
Scope.HEALTHKIT_STEP_WRITE,
Scope.HEALTHKIT_STEP_READ,
Scope.HEALTHKIT_STEP_REALTIME,
Scope.HEALTHKIT_CALORIES_READ,
Scope.HEALTHKIT_CALORIES_WRITE
];
AuthHuaweiId result = await HealthAuth.signIn(scopes);
Provides functions to create and manage user activities.
Method | Return Type | Description |
---|---|---|
addActivityRecord | Future<String> | Inserts a specified activity record and corresponding data to the HUAWEI Health platform. |
getActivityRecord | Future<List<ActivityRecord>> | Reads ActivityRecord data from the HUAWEI Health platform. |
beginActivityRecord | Future<void> | Starts a new ActivityRecord for the current app. |
endActivityRecord | Future<List<ActivityRecord>> | Stops the ActivityRecord of a specific ID. |
endAllActivityRecords | Future<List<ActivityRecord>> | Stops all the ongoing ActivityRecords. |
Inserts a specified activity record and corresponding data to the HUAWEI Health platform.
Parameter | Type | Description |
---|---|---|
activityRecordInsertOptions | ActivityRecordInsertOptions | Request parameter class for inserting an activity record, including the associated sampling dataset and sampling points to the platform. |
Type | Description |
---|---|
Future<String> | Result message. |
// Create start time that will be used to add activity record.
DateTime startTime = DateTime.now();
// Create end time that will be used to add activity record.
DateTime endTime = DateTime.now().add(Duration(hours: 2));
// Build an ActivityRecord object
ActivityRecord activityRecord = ActivityRecord(
startTime: startTime,
endTime: endTime,
id: 'ActivityRecordRun1',
name: 'BeginActivityRecordSteps',
description: 'This is a test for ActivityRecord',
);
// Build the dataCollector object
DataCollector dataCollector = DataCollector(
dataGenerateType: DataGenerateType.DATA_TYPE_RAW,
dataType: DataType.DT_CONTINUOUS_STEPS_DELTA,
name: 'AddActivityRecord1');
// You can use sampleSets to add more sample points to the sampling dataset.
// Build a list of sampling point objects and add it to the sampling dataSet
List<SamplePoint> samplePoints = [
SamplePoint(
startTime: startTime,
endTime: endTime,
fieldValueOptions: FieldInt(Field.FIELD_STEPS_DELTA, 1024),
timeUnit: TimeUnit.MILLISECONDS)
];
SampleSet sampleSet = SampleSet(dataCollector, samplePoints);
String result = await ActivityRecordsController.addActivityRecord(
ActivityRecordInsertOptions(
activityRecord: activityRecord, sampleSets: [sampleSet]),
);
Future<List<ActivityRecord>> getActivityRecord(ActivityRecordReadOptions activityRecordReadOptions) async
Reads ActivityRecord data from the HUAWEI Health platform.
Parameter | Type | Description |
---|---|---|
activityRecordReadOptions | ActivityRecordReadOptions | Defines the activity record read options for an ActivityRecord read process. |
Type | Description |
---|---|
Future<List<ActivityRecord>> | Obtained ActivityRecord objects |
// Create start time that will be used to read activity record.
DateTime startTime = DateTime.now().subtract(Duration(days: 1));
// Create end time that will be used to read activity record.
DateTime endTime = DateTime.now().add(Duration(hours: 3));
ActivityRecordReadOptions activityRecordReadOptions =
ActivityRecordReadOptions(
startTime: startTime,
endTime: endTime,
timeUnit: TimeUnit.MILLISECONDS,
dataType: DataType.DT_CONTINUOUS_STEPS_DELTA);
List<ActivityRecord> result =
await ActivityRecordsController.getActivityRecord(activityRecordReadOptions);
Starts a new activity record for the current app.
Parameter | Type | Description |
---|---|---|
activityRecord | ActivityRecord | ActivityRecord object to be started. |
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
// Build an ActivityRecord object
ActivityRecord activityRecord = ActivityRecord(
id: 'ActivityRecordRun0',
name: 'BeginActivityRecord',
description: 'This is ActivityRecord begin test!',
activityTypeId: HiHealthActivities.running,
startTime: DateTime.now().subtract(Duration(hours: 1)),
);
await ActivityRecordsController.beginActivityRecord(activityRecord);
Stops the ActivityRecord with the specified id.
Parameter | Type | Description |
---|---|---|
activityRecordId | String | Id of the ActivityRecord to be stopped. |
Type | Description |
---|---|
Future<List<ActivityRecord>> | List of ActivityRecord objects that stopped. |
List<ActivityRecord> result =
await ActivityRecordsController.endActivityRecord(
'ActivityRecordRun0');
Ends all the ongoing activity records.
Type | Description |
---|---|
Future<List<ActivityRecord>> | List of ActivityRecord objects that stopped. |
// Return the list of activity records that have stopped
List<ActivityRecord> result =
await ActivityRecordsController.endAllActivityRecords();
Provides the capabilities to read data in real time and cancel the reading.
Note: AutoRecorderController supports real-time data reading only for DataType.DT_CONTINUOUS_STEPS_TOTAL.
Method | Return Type | Description |
---|---|---|
startRecord | Future<void> | Starts real-time data reading by specifying the data type. |
stopRecord | Future<void> | Stops the ongoing AutoRecorder service. |
autoRecorderStream | Stream<SamplePoint> | Stream that emits SamplePoints objects after startRecord is activated. |
Starts real-time data reading by specifying the data type.
This method will trigger a foreground service that has an ongoing(sticky) notification. The notification properties can be customized by specifying a NotificationProperties instance. The SamplePoint results that include the count of steps are emitted to the autoRecorderStream.
If there is an ongoing AutoRecorder service present, an exception will be thrown.
Parameter | Type | Description |
---|---|---|
dataType | DataType | Data type specified for starting the real-time data reading. |
notificationProperties | NotificationProperties | The customization properties for the ongoing notification. Including but not limited to notification title, text, subtext. |
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
await AutoRecorderController.startRecord(
DataType.DT_CONTINUOUS_STEPS_TOTAL,
NotificationProperties(
title: "HMS Flutter Health Demo",
text: "Counting steps",
subText: "this is a subtext",
showChronometer: true),
);
Stops the ongoing AutoRecorder service. If there is no ongoing AutoRecorder service this method will throw an exception.
Parameter | Type | Description |
---|---|---|
dataType | DataType | Data type specified for stopping the real-time data reading. |
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
await AutoRecorderController.stopRecord(
DataType.DT_CONTINUOUS_STEPS_TOTAL);
Stream that emits SamplePoint objects after startRecord is activated.
Type | Description |
---|---|
Stream<SamplePoint> | Listenable stream that emits SamplePoint objects. |
AutoRecorderController.autoRecorderStream.listen(_onAutoRecorderEvent);
void _onAutoRecorderEvent(SamplePoint res) {
// Obtain the step values
Map<String, dynamic> = res.fieldValues;
}
Determines the API for data management. The user can use this API to insert, delete, update, and read data, as well as query the data statistics of the current day and past days.
Method | Return Type | Description |
---|---|---|
init | Future<DataController> | Initializes a DataController instance by a list of HiHealthOption objects that define data types and read/write permissions. |
clearAll | Future<void> | Clears all data inserted by the app from the device and the cloud. |
delete | Future<void> | Deletes inserted sampling datasets by specifying a time range or deletes them all. It can also be used to delete workout records. |
insert | Future<void> | Inserts a sampling dataset into the Health platform. |
read | Future<ReadReply> | Reads user data. |
readTodaySummation | Future<SampleSet> | Reads the summary data of a specified data type of the current day. |
readDailySummation | Future<SampleSet> | Reads the daily statistics of a specified data type. |
update | Future<void> | Updates existing data. |
Initializes a DataController instance by a list of HiHealthOption objects that define data types and read/write permissions.
Parameter | Type | Description |
---|---|---|
hiHealthOptions | List<HiHealthOption> | List of HiHealthOption objects for specifying data types and permissions regarding those data types. |
Type | Description |
---|---|
Future<DataController> | a DataController instance. |
DataController dataController = await DataController.init(<HiHealthOption>[
HiHealthOption(DataType.DT_CONTINUOUS_STEPS_DELTA, AccessType.read),
HiHealthOption(DataType.DT_CONTINUOUS_STEPS_DELTA, AccessType.write),
]);
Clears all data inserted by the app from the device and the cloud.
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
await dataController.clearAll();
Deletes inserted sampling datasets by specifying a time range or deletes them all. It can also be used to delete workout records.
Parameter | Type | Description |
---|---|---|
options | DeleteOptions | DeleteOptions object, used to specify the data collector, data type, and time range of data to be deleted. |
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
// Build the dataCollector object
DataCollector dataCollector = DataCollector(
dataType: DataType.DT_CONTINUOUS_STEPS_DELTA,
dataGenerateType: DataGenerateType.DATA_TYPE_RAW,
dataStreamName: 'my_data_stream');
// Build the time range for the deletion: start time and end time.
DeleteOptions deleteOptions = DeleteOptions(
dataCollectors: <DataCollector>[dataCollector],
startTime: DateTime.parse('2020-10-10 08:00:00'),
endTime: DateTime.parse('2020-10-10 12:30:00'));
// Call the method with the constructed DeleteOptions instance.
dataController.delete(deleteOptions);
Inserts a sampling dataset into the Health platform.
Parameter | Type | Description |
---|---|---|
sampleSet | SampleSet | Sampling dataset to be inserted to the HUAWEI Health platform. |
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
// Build the dataCollector object
DataCollector dataCollector = DataCollector(
dataType: DataType.DT_CONTINUOUS_STEPS_DELTA,
dataStreamName: 'my_data_stream',
dataGenerateType: DataGenerateType.DATA_TYPE_RAW);
// You can use sampleSets to add more sampling points to the sampling dataset.
SampleSet sampleSet = SampleSet(dataCollector, <SamplePoint>[
SamplePoint(
startTime: DateTime.parse('2020-10-10 12:00:00'),
endTime: DateTime.parse('2020-10-10 12:12:00'),
fieldValueOptions: FieldInt(Field.FIELD_STEPS_DELTA, 100))
]);
// Call the method with the constructed sample set.
dataController.insert(sampleSet);
Reads user data. You can read data by time, device, data collector, and more by specifying the related parameters in ReadOptions.
Parameter | Type | Description |
---|---|---|
readOptions | ReadOptions | ReadOptions object, for specifying parameters in the data reading request. It is used to specify the data collector, data type, the time range for the requested data, and more. |
Type | Description |
---|---|
Future<ReadReply> | Read data. The start time or end time of the returned data points is within the specified time range. |
// Build the dataCollector object
DataCollector dataCollector = DataCollector(
dataType: DataType.DT_CONTINUOUS_STEPS_DELTA,
dataGenerateType: DataGenerateType.DATA_TYPE_RAW,
dataStreamName: 'my_data_stream');
// Build the time range for the query: start time and end time.
ReadOptions readOptions = ReadOptions(
dataCollectors: [dataCollector],
startTime: DateTime.parse('2020-10-10 12:00:00'),
endTime: DateTime.parse('2020-10-10 12:12:00'),
)..groupByTime(10000);
// Call the method with the constructed ReadOptions instance.
ReadReply readReply = await dataController.read(readOptions);
Reads the summary data of a specified data type of the current day. If the related data type does not support aggregation statistics, an exception will be thrown.
Parameter | Type | Description |
---|---|---|
dataType | DataType | Data type to be read.Currently, only the following data types are supported: Calories: DataType.DT_CONTINUOUS_CALORIES_BURNT Distance: DataType.DT_CONTINUOUS_DISTANCE_DELTA Heart rate: DataType.DT_INSTANTANEOUS_HEART_RATE Incremental step count: DataType.DT_CONTINUOUS_STEPS_DELTA Weight: DataType.DT_INSTANTANEOUS_BODY_WEIGHT Sleep: DataType.DT_CONTINUOUS_SLEEP Stress: DataType.DT_INSTANTANEOUS_STRESS |
Type | Description |
---|---|
Future<SampleSet> | The statistical value of the data type. Calculation will be performed on all the queried data points with the start time or end time being in the specified time range, and the statistical results will be returned. |
SampleSet sampleSet = await _dataController
.readTodaySummation(DataType.DT_CONTINUOUS_STEPS_DELTA);
Reads the daily statistics of a specified data type. You can set the data type, start time, and end time to read the daily statistics in the specified period. If the related data type does not support aggregation statistics, an exception will be thrown.
Parameter | Type | Description |
---|---|---|
dataType | DataType | Data type to be read. Currently, only the following data types are supported: Calories: DataType.DT_CONTINUOUS_CALORIES_BURNT Distance: DataType.DT_CONTINUOUS_DISTANCE_DELTA Heart rate: DataType.DT_INSTANTANEOUS_HEART_RATE Incremental step count: DataType.DT_CONTINUOUS_STEPS_DELTA Weight: DataType.DT_INSTANTANEOUS_BODY_WEIGHT Sleep: DataType.DT_CONTINUOUS_SLEEP Stress: DataType.DT_INSTANTANEOUS_STRESS |
startTime | int | An 8-digit integer in the format of YYYYMMDD, for example, 20200803 . |
endTime | int | An 8-digit integer in the format of YYYYMMDD, for example, 20200903 . |
Type | Description |
---|---|
Future<SampleSet> | All data points with the start time or end time being in the specified time range will be queried. The sum value of the queried data points will be returned. Different from the readTodaySummation method, the readDailySummation method can be used to query the data of multiple days, with a statistical value provided for each day. |
SampleSet sampleSet = await dataController.readDailySummation(
DataType.DT_CONTINUOUS_STEPS_DELTA, 20201002, 20201215);
Updates existing data. If the update target does not exist, a new entry of data will be inserted.
Parameter | Type | Description |
---|---|---|
options | UpdateOptions | UpdateOptions object, used to specify the time range of the data to be updated and the updated values. |
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
// Build the dataCollector object
DataCollector dataCollector = DataCollector(
dataType: DataType.DT_CONTINUOUS_STEPS_DELTA,
dataStreamName: 'my_data_stream_name',
dataGenerateType: DataGenerateType.DATA_TYPE_RAW);
// You can use sampleSets to add more sampling points to the sampling dataset.
SampleSet sampleSet = SampleSet(dataCollector, <SamplePoint>[
SamplePoint(
startTime: DateTime.parse('2020-12-12 09:00:00'),
endTime: DateTime.parse('2020-12-12 09:05:00'),
fieldValueOptions: FieldInt(Field.FIELD_STEPS_DELTA, 120))
]);
// Build a parameter object for the update.
// Note: (1) The start time of the modified object updateOptions can not be greater than the minimum
// value of the start time of all sample data points in the modified data sample set
// (2) The end time of the modified object updateOptions can not be less than the maximum value of the
// end time of all sample data points in the modified data sample set
UpdateOptions updateOptions = UpdateOptions(
startTime: DateTime.parse('2020-12-12 08:00:00'),
endTime: DateTime.parse('2020-12-12 09:25:00'),
sampleSet: sampleSet);
await _dataController.update(updateOptions);
Provides the setting-related functions.
Method | Return Type | Description |
---|---|---|
addDataType | Future<DataType> | Creates and adds a customized data type. |
readDataType | Future<DataType> | Reads the data type based on the data type name. |
disableHiHealth | Future<void> | Disables the Health Kit function, cancels user authorization, and cancels all data records. (The task takes effect in 24 hours.) |
checkHealthAppAuthorization | Future<void> | Checks the user privacy authorization to Health Kit. If the authorization has not been granted, the user will be redirected to the authorization screen where they can authorize the Huawei Health app to open data to Health Kit. |
getHealthAppAuthorization | Future<bool> | Checks the user privacy authorization to Health Kit. |
Creates and adds a customized data type. The name of the created data type must be prefixed with the package name of the app Otherwise, the creation fails. The same data type can't be added more than once otherwise an exception will be thrown.
Parameter | Type | Description |
---|---|---|
options | DataTypeAddOptions | Request options for creating the data type. |
Type | Description |
---|---|
Future<DataType> | Created data type. |
DataTypeAddOptions options = DataTypeAddOptions(
"com.huawei.hms.flutter.health_example.myCustomDataType",
[Field.newIntField("myIntField"), Field.FIELD_ALTITUDE]);
final DataType dataTypeResult =
await SettingController.addDataType(options);
Reads the data type based on the data type name.
Parameter | Type | Description |
---|---|---|
dataTypeName | String | Name of the custom data type to read. |
Type | Description |
---|---|
Future<DataType> | Obtained data type. |
final DataType dataTypeResult = await SettingController.readDataType(
"com.huawei.hms.flutter.health_example.myCustomDataType",
);
Disables the Health Kit function, cancels user authorization, and cancels all data records.
Note: The task takes effect in 24 hours.
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
await SettingController.disableHiHealth();
Checks the user privacy authorization to Health Kit. If the authorization has not been granted, the user will be redirected to the authorization screen where they can authorize the Huawei Health app to open data to Health Kit.
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
await SettingController.checkHealthAppAuthorization();
Checks the user privacy authorization to Health Kit.
Type | Description |
---|---|
Future<bool> | Whether the user privacy authorization has been granted to Health Kit. Returns true if Authorized, false otherwise. |
bool result = await SettingController.getHealthAppAuthorization();
Provides authorization management APIs that can be used to view and revoke the granted permissions.
Method | Return Type | Description |
---|---|---|
getAppId | Future<String> | Obtains the application id from the agconnect-services.json file. |
getScopes | Future<ScopeLangItem> | Queries the list of permissions granted to your app. |
revoke | Future<void> | Revokes all permissions granted to your app. |
revokeWithScopes | Future<void> | Revokes certain Health Kit related permissions granted to your app. |
Obtains the application id from the agconnect-services.json file.
Type | Description |
---|---|
Future<String> | Application ID. |
final String appId = await ConsentsController.getAppId();
Queries the list of permissions granted to your app.
Parameter | Type | Description |
---|---|---|
lang | String | Language code. If the specified value is invalid, en-us will be used. |
appId | String | ID of your app. |
Type | Description |
---|---|
Future<ScopeLangItem> | List of permissions that have been granted to your app. |
final String appId = await ConsentsController.getAppId();
ScopeLangItem scopeLangItem =
await ConsentsController.getScopes('en-gb', appId);
Revokes all permissions granted to your app.
Parameter | Type | Description |
---|---|---|
appId | String | ID of your app. |
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
final String appId = await ConsentsController.getAppId();
await ConsentsController.revoke(appId);
Revokes certain Health Kit related permissions granted to your app.
Parameter | Type | Description |
---|---|---|
appId | String | ID of your app. |
scopes | List<Scope> | Scopes to be revoked. |
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
final String appId = await ConsentsController.getAppId();
await ConsentsController.revokeWithScopes(appId, [
Scope.HEALTHKIT_DISTANCE_WRITE,
Scope.HEALTHKIT_DISTANCE_READ,
]);
HMSLogger is used for sending usage analytics of Health Kit SDK's methods to improve the service quality.
HMSLogger service is enabled by default.
Method | Return Type | Description |
---|---|---|
enableLogger | Future<void> | Enables HMSLogger service. |
disableLogger | Future<void> | Disables HMSLogger service. |
Enables HMS Plugin Method Analytics which is used for sending usage analytics of Health Kit SDK's methods to improve the service quality.
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
await HMSLogger.enableLogger();
Disables HMS Plugin Method Analytics which is used for sending usage analytics of Health Kit SDK's methods to improve the service quality.
Type | Description |
---|---|
Future<void> | Future result of an execution that returns no value. |
await HMSLogger.disableLogger();
Request object classes for CRUD operations. The summary of classes is described in the table below.
Name | Description |
---|---|
ActivityRecordInsertOptions | Request parameter class for inserting an activity record, including the associated sampling dataset and sampling points to the platform. |
ActivityRecordReadOptions | Defines the activity record read options for an ActivityRecord read process |
DataTypeAddOptions | Defines the options for adding a customized data type to Health Kit. |
DeleteOptions | Defines the delete options for an ActivityRecord delete process. |
ReadOptions | Request class for reading data. |
UpdateOptions | Request parameter class for updating data. |
HiHealthOption | Defines the request permissions. |
Request parameter class for inserting an activity record, including the associated sampling dataset and sampling points to the platform.
Name | Type | Description |
---|---|---|
activityRecord | ActivityRecord | ActivityRecord to be inserted. |
sampleSets | List<SampleSet> | Sampling datasets for the request. |
Constructor | Description |
---|---|
ActivityRecordInsertOptions({ActivityRecord activityRecord, List<SampleSet> sampleSets}) | Default constructor. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two ActivityRecordInsertOptions objects are the same. |
hashCode | int | Returns the hash code of the current object. |
Default constructor.
Parameter | Type | Description |
---|---|---|
activityRecord | ActivityRecord | ActivityRecord to be inserted. |
sampleSets | List<SampleSets> | Sampling datasets for the request. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two ActivityRecordInsertOptions objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Defines the activity record read options for an ActivityRecord read process.
Name | Type | Description |
---|---|---|
activityRecordId | String | ID of the activity record to be read. |
activityRecordName | String | Name of the activity record to be read. |
startTime | DateTime | Start time. |
endTime | DateTime | End time. |
timeUnit | TimeUnit | Time unit. |
dataType | DataType | DataType of the ActivityRecord to be read. |
Constructor | Description |
---|---|
ActivityRecordReadOptions({String activityRecordId, String activityRecordName, DateTime startTime, DateTime endTime, TimeUnit timeUnit, DataType dataType}) | Default constructor. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
ActivityRecordsReadOptions
Default constructor.
The same fields apply as in the properties table.
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Defines the options for adding a customized data type to Health Kit.
Name | Type | Description |
---|---|---|
name | String | Name of the DataType. It Must be prefixed with the package name. |
fields | List<Field> | Field to be added to DataType. |
Constructor | Description |
---|---|
DataTypeAddOptions(String name, List<Field> fields) | Default constructor. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two DataTypeAddOptions objects are the same. |
hashCode | int | Returns the hash code of the current object. |
Default Constructor.
The same fields apply as in the properties table.
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two DataTypeAddOptions objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Defines the delete options for an ActivityRecord delete process.
Name | Type | Description |
---|---|---|
deleteAllData | bool | Should be set to true if all the data types are marked for deletion. |
deleteAllActivityRecords | bool | Should be set to true if all the activity records are marked for deletion. |
activityRecords | List<ActivityRecord> | List of activity records to be deleted. |
dataCollectors | List<DataCollector> | List of data collectors whose data is to be deleted. |
dataTypes | List<DataType> | List of data types whose data is to be deleted. |
startTime | DateTime | Start time for data to be deleted. |
endTime | DateTime | End time for data to be deleted. |
timeUnit | TimeUnit | TimeUnit for data to be deleted. |
Method | Return Type | Description |
---|---|---|
setTimeInterval | void | Sets the start time and end time for data to be deleted. |
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two DeleteOptions objects are the same. |
hashCode | int | Returns the hash code of the current object. |
DeleteOptions
Default constructor.
The same parameters apply as in the properties table.
Sets the start time and end time for data to be deleted. The start time must be greater than 0, and the end time must not be earlier than the start time.
Parameter | Type | Description |
---|---|---|
startTime | DateTime | Start Time. |
endTime | DateTime | End Time. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two DeleteOptions objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Request class for reading data. The request can be used to specify the type of data to be read and grouped parameters. The read request requires the setting of a time range and allows data to be read in detail or summary mode.
Name | Type | Description |
---|---|---|
startTime | DateTime | Start time of the read request. |
endTime | DateTime | End time of the read request. |
timeUnit | TimeUnit | Time unit of the read request. |
duration | int | Duration for grouped data. |
dataCollectors | List<DataCollector> | Data collectors for reading data. |
dataTypes | List<DataType> | Data types for reading data. |
pageSize | int | The maximum number of pages for the paginated query results. |
allowRemoteInquiry | bool | Allows for query on the cloud. |
Constructor | Description |
---|---|
ReadOptions({DateTime startTime, DateTime endTime, TimeUnit timeUnit, int pageSize, bool allowRemoteInquiry, List<DataCollector> dataCollectors, List<DataType> dataTypes}) | Default Constructor. |
Method | Return Type | Description |
---|---|---|
groupByTime | void | Sets the group type to TYPE_TIME and sets the duration for each group. |
polymerizeByDataType | void | Adds a new data type to the grouped data and sets the type of the grouped data to be returned. |
polymerizeByDataCollector | void | Adds a new data collector to the grouped data and sets the type of the grouped data to be returned. |
toMap | Map<String, dynamic> | Returns a map representation of the object. |
ReadOptions
Default constructor.
Parameter | Type | Description |
---|---|---|
startTime | DateTime | Start time of the read request. |
endTime | DateTime | End time of the read request. |
timeUnit | TimeUnit | Time unit of the read request. |
dataCollectors | List<DataCollector> | Data collectors for reading data. |
dataTypes | List<DataType> | Data types for reading data. |
pageSize | int | The maximum number of pages for the paginated query results. |
allowRemoteInquiry | bool | Allows for query on the cloud. |
Sets the group type to TYPE_TIME and sets the duration for each group.
Parameter | Type | Description |
---|---|---|
duration | int | Duration. |
timeUnit | TimeUnit | Time Unit. |
Adds a new data type to the grouped data and sets the type of the grouped data to be returned.
Parameter | Type | Description |
---|---|---|
inputDataType | DataType | Type of data to be grouped. |
outputDataType | DataType | Type of the grouped data to be returned. |
Adds a data collector for reading data.
Parameter | Type | Description |
---|---|---|
dataCollector | DataCollector | Data collector to add. |
outputDataType | DataType | Type of the grouped data to be returned. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Request parameter class for updating data for a specified period of time to the HUAWEI Health platform.
Name | Type | Description |
---|---|---|
startTime | DateTime | Start time for update request. |
endTime | DateTime | End time for update request. |
timeUnit | TimeUnit | Time unit of the update request. |
sampleSet | SampleSet | Sampling dataset for updating data. |
Constructor | Description |
---|---|
UpdateOptions({DateTime startTime, DateTime endTime,TimeUnit timeUnit=TimeUnit.MILLISECONDS, SampleSet sampleSet}) | Default constructor. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
UpdateOptions({DateTime startTime, DateTime endTime,TimeUnit timeUnit=TimeUnit.MILLISECONDS, SampleSet sampleSet})
Default constructor.
The same parameters apply as in the properties table.
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Defines the request permissions. Permissions are defined by DataType, which determines the Health Kit scopes authorized to the signed-in HUAWEI ID.
Name | Type | Description |
---|---|---|
dataType | DataType | Data type that the developer needs to access. |
accessType | AccessType | AccessType option for data type. Values are AccessType.read and AccessType.write . |
Constructor | Description |
---|---|
HiHealthOption(DataType dataType, AccessType accessType) | Default constructor. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
==(equals operator) | bool | Checks whether two HiHealthOption objects are the same. |
hashCode | int | Returns the hash code of the current object. |
Default constructor.
The same parameters apply as in the properties table.
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two HiHealthOption objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Dataset classes for interacting with the data provided by Health Kit. The summary of classes is described in the table below.
Name | Description |
---|---|
ActivityRecord | Activity record class, which records the basic information about an activity of the user. |
ActivitySummary | Activity summary class. |
PaceSummary | Pace summary class. |
DataCollector | Defines a unique data collector. |
DataType | Data types defined by HUAWEI Health Kit. |
Field | Fields for common data types. |
SamplePoint | Sampling point class, which presents the sampled data of a specific type collected by a specific data collector at a given time or within a time range. |
FieldValueOptions | Abstract base class for FieldInt, FieldLong, FieldFloat, FieldMap, FieldString, FieldValueOptions types. |
SampleSet | The sampling dataset class represents the container for storing sampling points. |
ScopeLangItem | List of permissions that have been granted to your app. |
Scope | Scope constant class, which is used to apply for scopes to access Health Kit data from users. |
Activity record class, which records the basic information about an activity of the user. For example, for an outdoor running activity, information including the start time, end time, activity record name, identifier, description, activity type (as defined in HiHealthActivities, and activity duration will be recorded.
Name | Type | Description |
---|---|---|
startTime | DateTime | The start time of the activity record. |
endTime | DateTime | The end time of the activity record. |
activeTimeMillis | int | Activity duration in milliseconds. |
name | String | Name of the activity record. |
id | String | Identifier of the activity record. |
description | String | Description of the activity record. |
timeZone | String | Time Zone. |
activityTypeId | String | Activity type corresponding to the activity record. |
activitySummary | ActivitySummary | Activity summary. |
Method | Return Type | Description |
---|---|---|
isKeepGoing | bool | Indicates whether an activity record is in progress. If the activity record has ended, the value false will be returned. |
hasDurationTime | bool | Indicates whether the activity record has durations. |
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two ActivityRecord objects are the same. |
hashCode | int | Returns the hash code of the current object. |
ActivityRecord
Default constructor.
The same parameters apply as in the properties table.
Indicates whether an activity record is in progress. If the activity record has ended, the value false
will be returned.
Type | Description |
---|---|
bool | true if activity record is in progress, false otherwise. |
Indicates whether the activity record has durations.
Type | Description |
---|---|
bool | true if activity record has durations false otherwise. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two ActivityRecord objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Activity summary class.
Name | Type | Description |
---|---|---|
paceSummary | PaceSummary | PaceSummary instance. |
dataSummary | List<SamplePoint> | Statistical data points that consist from SamplePoints. |
Constructor | Description |
---|---|
ActivitySummary({PaceSummary paceSummary, @required List<SamplePoint> dataSummary}) | Default constructor. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two ActivitySummary objects are the same. |
hashCode | int | Returns the hash code of the current object. |
Default constructor.
The same parameters apply as in the properties table.
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two ActivitySummary objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Pace summary class.
Name | Type | Description |
---|---|---|
britishPaceMap | Map<String, double> | Pace per mile. |
britishPartTimeMap | Map<String, double> | Segment data table in the imperial system. |
paceMap | Map<String, double> | Pace per kilometer. |
partTimeMap | Map<String, double> | Segment data table in the metric system. |
sportHealthPaceMap | Map<String, double> | Health pace records. |
avgPace | double | Average pace. |
bestPace | double | Optimal pace. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two PaceSummary objects are the same. |
hashCode | int | Returns the hash code of the current object. |
PaceSummary
Default constructor.
The same parameters apply as in the properties table.
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two PaceSummary objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Defines a unique data collector. A data collector provides the raw data collected from a phone or external device. Data from multiple data collectors can be converted or combined and therefore becomes derived data. Each sampling point must have a corresponding data collector. When a data collector is created, a unique identifier will be generated for it. The identifier consists of the data collector type, device information, package name of the app, and more.
DataGenerateType options.
Value | Description |
---|---|
DATA_TYPE_RAW | Raw data type. |
DATA_TYPE_DERIVED | Derived data type. |
DATA_TYPE_CLEAN | Clean data type. |
DATA_TYPE_CONVERTED | Converted data type. |
DATA_TYPE_MERGED | Merged data type. |
DATA_TYPE_POLYMERIZED | Grouped data type. |
Name | Type | Description |
---|---|---|
name | String | The name of the data collector. The input parameter can be null or a string of 1 to 300 characters. |
dataGenerateType | DataGenerateType | The type of the data collector, such as raw and derived. |
dataStreamName | String | The name of the data stream. The input parameter can be empty or a string of 1 to 300 characters. |
dataStreamId | String | The unique identifier of the data collector. |
dataType | DataType | The data type. |
deviceId | String | The identifier of the device. |
deviceInfo | DeviceInfo | The Device information. |
isLocalized | bool | Whether the data collector is originated from the local device. The default value is false (non-local device). |
packageName | String | The package name of the app. The input parameter can be an empty string or a string of 1 to 300 characters. |
Method | Return Type | Description |
---|---|---|
getStandardByType | String | Obtains the standard type. |
getDataGenerateType | DataGenerateType | Obtains the type of the data collector. |
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two DataCollector objects are the same. |
hashCode | int | Returns the hash code of the current object. |
DataCollector
Default constructor.
The same parameters apply as in the properties table.
Obtains the standard type.
Parameter | Type | Description |
---|---|---|
type | int | Integer value of the standard. |
Type | Description |
---|---|
String | Standard name. |
Obtains the type of the data collector.
Parameter | Type | Description |
---|---|---|
value | int | Value of the DataGenerateType. The value should be in [0-5] range |
Type | Description |
---|---|
DataGenerateType | DataGenerateType that corresponds to integer value. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two DataCollector objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Data types defined by HUAWEI Health Kit. Each data type has a unique name for the identification purpose and each data type has its own meaning. For example, DT_CONTINUOUS_STEPS_DELTA indicates the number of steps taken since the last reading. You can also create you own data types with the addDataType API from the SettingController module.
Constant | Type | Description |
---|---|---|
DT_UNUSED_DATA_TYPE | DataType | Default data type. |
DT_CONTINUOUS_STEPS_DELTA | DataType | Steps taken since the last reading. The value range over 1 second is (0, 10], that over 1 minute is (0,600], and that over 1 hour is (0, 36000] |
DT_CONTINUOUS_STEPS_TOTAL | DataType | Total number of steps. This data type applies only to data query scenarios. |
DT_INSTANTANEOUS_STEPS_RATE | DataType | Number of steps per minute. |
DT_CONTINUOUS_STEPS_RATE_STATISTIC | DataType | Step cadence statistics. |
DT_CONTINUOUS_ACTIVITY_SEGMENT | DataType | Activity type within a period of time. |
DT_CONTINUOUS_CALORIES_CONSUMED | DataType | Calories consumed within a period of time (unit: kcal). |
DT_CONTINUOUS_CALORIES_BURNT | DataType | Total calories burnt within a period of time. This field is mandatory, and the unit is kcal. The value range over 1 second is (0, 0.555555555555556), that over 1 minute is (0,33.333333333333333), and that over 1 hour is (0, 2000]. |
DT_INSTANTANEOUS_CALORIES_BMR | DataType | Basic metabolic rate per day (unit: kcal). |
DT_INSTANTANEOUS_POWER_SAMPLE | DataType | Instantaneous sampling of power. |
DT_INSTANTANEOUS_ACTIVITY_SAMPLE | DataType | A single activity type within a period of time. |
DT_INSTANTANEOUS_HEART_RATE | DataType | Heart rate (unit: heartbeats per minute). This field is mandatory. The value range is (0, 255). |
DT_INSTANTANEOUS_LOCATION_SAMPLE | DataType | Location at a given time. |
DT_INSTANTANEOUS_LOCATION_TRACE | DataType | A point on the trajectory. |
DT_CONTINUOUS_DISTANCE_DELTA | DataType | Distance covered since the last reading (unit: meter). This field is mandatory. The value range over 1 second is (0, 100], that over 1 minute is (0, 6000], and that over 1 hour is (0, 360000]. |
DT_CONTINUOUS_DISTANCE_TOTAL | DataType | Accumulated distance covered (unit: meter). |
DT_CONTINUOUS_CALORIES_BURNT_TOTAL | DataType | Total calories. |
DT_INSTANTANEOUS_SPEED | DataType | Instantaneous speed on the ground (unit: m/s). |
DT_CONTINUOUS_BIKING_WHEEL_ROTATION_TOTAL | DataType | Number of rotations of the bicycle wheel within a period of time. |
DT_INSTANTANEOUS_BIKING_WHEEL_ROTATION | DataType | Instantaneous measurement of the rotational speed of the bicycle wheel per minute. |
DT_CONTINUOUS_BIKING_PEDALING_TOTAL | DataType | Total mileage of the bicycle since the start of the count (unit: meter). |
DT_INSTANTANEOUS_BIKING_PEDALING_RATE | DataType | Cycling speed at a time point (unit: m/s). |
DT_INSTANTANEOUS_HEIGHT | DataType | Height (unit: meter). This field is mandatory. The value range is (0.4, 2.6). |
DT_INSTANTANEOUS_BODY_WEIGHT | DataType | Weight (unit: kg). This field is mandatory. The value range is (1, 560). |
DT_INSTANTANEOUS_BODY_FAT_RATE | DataType | Body fat rate. |
DT_INSTANTANEOUS_NUTRITION_FACTS | DataType | Nutrient intake over a meal. |
DT_INSTANTANEOUS_HYDRATE | DataType | Water taken over a single drink (unit: liter). |
DT_CONTINUOUS_WORKOUT_DURATION | DataType | Workout duration (unit: minute). |
DT_CONTINUOUS_EXERCISE_INTENSITY | DataType | Workout intensity. |
DT_STATISTICS_SLEEP | DataType | Sleep statistics type. |
DT_CONTINUOUS_SLEEP | DataType | Sleep details. |
DT_INSTANTANEOUS_STRESS | DataType | Pressure details. |
DT_INSTANTANEOUS_STRESS_STATISTICS | DataType | Pressure statistics type. |
POLYMERIZE_CONTINUOUS_WORKOUT_DURATION | DataType | Workout duration over a period of time (unit: minute). |
POLYMERIZE_CONTINUOUS_ACTIVITY_STATISTICS | DataType | Summarized statistics of a specific activity type within a period of time. |
POLYMERIZE_CONTINUOUS_CALORIES_BMR_STATISTICS | DataType | Average, maximum, and minimum basic metabolic rates over a period of time (unit: kcal). |
POLYMERIZE_STEP_COUNT_DELTA | DataType | Step increment within a period of time. |
POLYMERIZE_DISTANCE_DELTA | DataType | Distance increment within a period of time. |
POLYMERIZE_CALORIES_CONSUMED | DataType | Total calories consumed. |
POLYMERIZE_CALORIES_EXPENDED | DataType | Total calories consumed within a period of time (unit: kcal). |
POLYMERIZE_CONTINUOUS_EXERCISE_INTENSITY_STATISTICS | DataType | Heartbeat intensity statistics. |
POLYMERIZE_CONTINUOUS_HEART_RATE_STATISTICS | DataType | Average, maximum, and minimum heartbeats per minute within a period of time. |
POLYMERIZE_CONTINUOUS_LOCATION_BOUNDARY_RANGE | DataType | Activity boundaries within a period of time. |
POLYMERIZE_CONTINUOUS_POWER_STATISTICS | DataType | Power within a period of time (including the maximum, minimum, and average power in the unit of watt). |
POLYMERIZE_CONTINUOUS_SPEED_STATISTICS | DataType | Ground speed (including the maximum, minimum, and average speed in the unit of m/s). |
POLYMERIZE_CONTINUOUS_BODY_FAT_RATE_STATISTICS | DataType | Body fat rate over a period of time (including the maximum, minimum, and average values). |
POLYMERIZE_CONTINUOUS_BODY_WEIGHT_STATISTICS | DataType | Weight over a period of time (including maximum, minimum, and average values in the unit of kg). |
POLYMERIZE_CONTINUOUS_HEIGHT_STATISTICS | DataType | Height over a period of time (including maximum, minimum, and average values in the unit of meter). |
POLYMERIZE_CONTINUOUS_NUTRITION_FACTS_STATISTICS | DataType | Sum of nutrient intake over a period of time. |
POLYMERIZE_HYDRATION | DataType | Water intake over a period of time (unit: liter). |
Name | Type | Description |
---|---|---|
name | String | Name. The value must be a string of 1 to 300 characters. |
packageName | String | App package name. |
scopeNameRead | String | Read permission of the data type. The value can be an empty string or a string of 1 to 1000 characters. |
scopeNameWrite | String | Write permission of the data type. The value can be an empty string or a string of 1 to 1000 characters. |
fields | List<Field> | Attribute list. |
isPolymerizedFlag | bool | Indicates whether it is a grouped data type. |
isSelfDefined | bool | Whether the data type is a customized one. |
Constructor | Description |
---|---|
const DataType(String name, String scopeNameRead, String scopeNameWrite, List<Field> fields, {bool isPolymerizedFlag = false, bool isSelfDefined = false, String packageName = ""}) | Default constructor. |
Method | Return Type | Description |
---|---|---|
getMimeType | String | Adds a header name to the type. |
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
const DataType
Default constructor.
The same parameters apply as in the properties table.
Adds a header name to the type.
Parameter | Type | Description |
---|---|---|
dataType | DataType | Data Type. |
Type | Description |
---|---|
String | Header name. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Fields for common data types.
For all the Field Constants please visit the document for the HUAWEI Health Kit Flutter Plugin on the Huawei Developer website.
Name | Type | Description |
---|---|---|
format | int | Attribute type. |
name | String | Field Name. |
isOptional | bool | Indicates whether it is optional. |
Constructor | Description |
---|---|
const Field(String name, int format, {bool isOptional = false}) | Default constructor. |
const Field.newFloatField(String name) | Creates an attribute that contains float values. |
const Field.newIntField(String name) | Creates an attribute that contains integer values. |
const Field.newMapField(String name) | Creates an attribute that contains mapped values. |
const Field.newStringField(String name) | Creates an attribute that contains string values. |
const Field.newLongField(String name) | Creates an attribute that contains long values. (Note: this type matches with long on Java which can contain 64 bits. Dart's integer values are already 64 bits instead of Java's 32 bits.) |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two Field objects are the same. |
hashCode | int | Returns the hash code of the current object. |
Default constructor.
The same parameters apply as in the properties table.
Creates an attribute that contains float values.
Parameter | Type | Description |
---|---|---|
name | String | Field name. |
Creates an attribute that contains integer values.
Parameter | Type | Description |
---|---|---|
name | String | Field name. |
Creates an attribute that contains mapped values.
Parameter | Type | Description |
---|---|---|
name | String | Field name. |
Creates an attribute that contains string values.
Parameter | Type | Description |
---|---|---|
name | String | Field name. |
Creates an attribute that contains long values.
Note: this type matches with long on java which can contain 64 bits. Dart's integer values are already 64 bits instead of Java's 32 bits.
Parameter | Type | Description |
---|---|---|
name | String | Field name. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two Field objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Sampling point class, which presents the sampled data of a specific type collected by a specific data collector at a given time or within a time range. It stores the values of each dimension of the data type at the given time (or within the time range) and the start time and end time of the sampling operation.
The sampling modes of sampling points are classified into instantaneous sampling and continuous sampling based on the definition of data types.
When setting the sampling point time, you are advised to call setSamplingTime() for instantaneous sampling data and setTimeInterval() for continuous sampling data (make sure to set a valid time duration). In addition, you can also call setTimeInterval() to set the time for instantaneous sampling data. Make sure that the passed start time and end time are the same. Otherwise, the creation will fail. The setSamplingTime() API can not be used when creating the continuous sampling point. Otherwise, the creation will fail. This API can be used to update the end time of a created continuous sampling point. After the API is called, only the end time will be updated.
Name | Type | Description |
---|---|---|
id | int | ID of the sampling point. |
startTime | DateTime | Start time. |
endTime | DateTime | End Time. |
samplingTime | DateTime | Sampling timestamp. |
timeUnit | TimeUnit | Time unit. |
fieldValueOptions | FieldValueOptions | FieldValueOptions object that contains the field values that will be used for SamplePoint creation. |
dataCollector | DataCollector | Data collector. |
Method | Return Type | Description |
---|---|---|
getInsertionTime | DateTime | Obtains the insertion time of the sample point. |
setTimeInterval | void | Sets the sampling timestamp of data within an interval. |
setSamplingTime | void | Sets the sampling timestamp of instantaneous data. |
fieldValues | Map<String, dynamic> | Obtains the field values that are returned from the native platform. |
getDataTypeId | int | Obtains DataTypeId. |
getDataType | DataType | Obtains the data type of the sampling point. |
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two SamplePoint objects are the same. |
hashCode | int | Returns the hash code of the current object. |
SamplePoint
Default constructor.
The same parameters apply as in the properties table.
Obtains the insertion time of the sample point.
Type | Description |
---|---|
DateTime | Insertion time of the sample point |
Sets the sampling timestamp of data within an interval.
Parameter | Type | Description |
---|---|---|
startTime | DateTime | Start time. |
endTime | DateTime | End time. |
timeUnit | TimeUnit | Time unit. |
Sets the sampling timestamp of instantaneous data.
Parameter | Type | Description |
---|---|---|
timeStamp | DateTime | Timestamp. |
timeUnit | TimeUnit | Time unit. |
Obtains the field values that are returned from the native platform. For example, while using the AutoRecorderController API, the resulting step count data can be obtained from this field.
Type | Description |
---|---|
Map<String, dynamic> | Map that contains field values. |
Obtains DataTypeId.
Type | Description |
---|---|
int | Id of the data type. |
Obtains DataType.
Type | Description |
---|---|
DataType | DataType. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two SamplePoint objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Abstract base class for FieldInt, FieldLong, FieldFloat, FieldMap, FieldString, FieldValueOptions types. This class contain the specified Field and the corresponding value for that field. It can be used to specify field and value that can have different types for a SamplePoint object.
Name | Type | Description |
---|---|---|
field | Field | Field type. |
value | dynamic | Field value. |
Constructor | Description |
---|---|
FieldValueOptions(Field field, dynamic value) | Default constructor. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
==(equals operator) | bool | Checks whether two FieldValueOptions objects are the same. |
hashCode | int | Returns the hash code of the current object. |
Default constructor.
The same parameters apply as in the properties table.
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Checks whether two FieldValueOptions objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Derived from the FieldValuesOptions class. Sets the integer attribute value of a sampling point.
Name | Type | Description |
---|---|---|
field | Field | Field type. |
value | int | Integer field value. |
Constructor | Description |
---|---|
FieldInt(Field field, int value) | Default constructor. |
The inherited methods from the FieldValueOptions base class.
Default constructor.
The same parameters apply as in the properties table.
The inherited methods from the FieldValueOptions base class.
Derived from the FieldValuesOptions class. Sets the long integer attribute value of a sampling point. Different from FieldInt, this option's value will be set as long integer in Android Platfom.
Name | Type | Description |
---|---|---|
field | Field | Field type. |
value | int | Integer field value to be converted as long on Android Platform. |
Constructor | Description |
---|---|
FieldLong(Field field, int value) | Default constructor. |
The inherited methods from the FieldValueOptions base class.
Default constructor.
The same parameters apply as in the properties table.
Please refer to methods of FieldValueOptions
Derived from the FieldValuesOptions class. Sets the double-precision floating-point attribute value of a sampling point.
Name | Type | Description |
---|---|---|
field | Field | Field type. |
value | double | Floating field value. |
Constructor | Description |
---|---|
FieldFloat(Field field, double value) | Default constructor. |
The inherited methods from the FieldValueOptions base class.
Default constructor.
The same parameters apply as in the properties table.
Please refer to methods of FieldValueOptions
Derived from the FieldValuesOptions class. Sets the mapped attribute value of a sampling point.
Name | Type | Description |
---|---|---|
field | Field | Field type. |
value | Map<String, dynamic> | Mapped field value. |
Constructor | Description |
---|---|
FieldMap(Field field, Map<String, dynamic> value) | Default constructor. |
The inherited methods from the FieldValueOptions base class.
Default constructor.
The same parameters apply as in the properties table.
Please refer to methods of FieldValueOptions
Derived from the FieldValuesOptions class. Sets the string attribute value of a sampling point.
Name | Type | Description |
---|---|---|
field | Field | Field type. |
value | String | String field value. |
Constructor | Description |
---|---|
FieldString(Field field, String value) | Default constructor. |
The inherited methods from the FieldValueOptions base class.
Default constructor.
The same parameters apply as in the properties table.
Please refer to methods of FieldValueOptions
The sampling dataset class represents the container for storing sampling points. The sampling points stored in a sampling dataset must be from the same data collector (but their raw data collectors can be different). This class is usually used to insert or read sampling data in batches.
Name | Type | Description |
---|---|---|
dataCollector | DataCollector | Data collector. |
samplePoints | List<SamplePoint> | A list of sampling points. |
Constructor | Description |
---|---|
SampleSet(DataCollector dataCollector, List<SamplePoint> samplePoints) | Default constructor. |
Method | Return Type | Description |
---|---|---|
getDataType | DataType | Obtains the data type from the data collector of the SampleSet. |
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two SampleSet objects are the same. |
hashCode | int | Returns the hash code of the current object. |
Default constructor.
The same parameters apply as in the properties table.
Obtains the data type from the data collector of the SampleSet.
Type | Description |
---|---|
DataType | Data Type. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two SampleSet objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
List of permissions that have been granted to your app.
Name | Type | Description |
---|---|---|
url2Desc | Map<String, String> | Mapping between the permission scope URL and description. |
authTime | String | Time when the permission is granted. |
appName | String | Application name. |
appIconPath | String | Path to the app icon image. |
Constructor | Description |
---|---|
ScopeLangItem({Map<String, String> url2Desc, String authTime, String appName, String appIconPath}) | Default constructor. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
==(equals operator) | bool | Checks whether two ScopeLangItem objects are the same. |
hashCode | int | Returns the hash code of the current object. |
Default constructor.
The same parameters apply as in the properties table.
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Checks whether two ScopeLangItem objects are the same.
Parameter | Type | Description |
---|---|---|
other | Object | Object to compare. |
Type | Description |
---|---|
bool | Comparison result: true if equals, false otherwise. |
Returns the hash code of the current object.
Type | Description |
---|---|
int | Calculated hash value. |
Scope constant class, which is used to apply for scopes to access Health Kit data from users.
Constant | Type | Description |
---|---|---|
HEALTHKIT_ACTIVITY_READ | String | Views the activity data (such as activity points, workout, strength, running posture, cycling, and activity duration) in HUAWEI Health Kit. |
HEALTHKIT_ACTIVITY_WRITE | String | Stores the activity data (such as activity points, workout, strength, running posture, cycling, and activity duration) in HUAWEI Health Kit. |
HEALTHKIT_BLOODGLUCOSE_READ | String | Views the blood glucose data in HUAWEI Health Kit. |
HEALTHKIT_BLOODGLUCOSE_WRITE | String | Stores the blood glucose data in HUAWEI Health Kit. |
HEALTHKIT_CALORIES_READ | String | Views the calories (including the BMR) in HUAWEI Health Kit. |
HEALTHKIT_CALORIES_WRITE | String | Stores calories (including the BMR) in HUAWEI Health Kit. |
HEALTHKIT_DISTANCE_READ | String | Views the distance and climbing height in HUAWEI Health Kit. |
HEALTHKIT_DISTANCE_WRITE | String | Stores the distance and climbing height in HUAWEI Health Kit. |
HEALTHKIT_HEARTRATE_READ | String | Views the heart rate data in HUAWEI Health Kit. |
HEALTHKIT_HEARTRATE_WRITE | String | Stores the heart rate data in HUAWEI Health Kit. |
HEALTHKIT_HEIGHTWEIGHT_READ | String | Views the height and weight in HUAWEI Health Kit. |
HEALTHKIT_HEIGHTWEIGHT_WRITE | String | Stores the height and weight in HUAWEI Health Kit. |
HEALTHKIT_LOCATION_READ | String | Views the location data (including the trajectory) in HUAWEI Health Kit. |
HEALTHKIT_LOCATION_WRITE | String | Stores the location data (including the trajectory) in HUAWEI Health Kit. |
HEALTHKIT_PULMONARY_READ | String | Views the pulmonary function data (e.g. VO2 Max) in HUAWEI Health Kit. |
HEALTHKIT_PULMONARY_WRITE | String | Stores the pulmonary function data (e.g. VO2 Max) in HUAWEI Health Kit. |
HEALTHKIT_SLEEP_READ | String | Views the sleep data in HUAWEI Health Kit. |
HEALTHKIT_SLEEP_WRITE | String | Stores the sleep data in HUAWEI Health Kit. |
HEALTHKIT_SPEED_READ | String | Views the speed in HUAWEI Health Kit. |
HEALTHKIT_SPEED_WRITE | String | Stores the speed in HUAWEI Health Kit. |
HEALTHKIT_STEP_READ | String | Views the step count in HUAWEI Health Kit. |
HEALTHKIT_STEP_WRITE | String | Stores the step count in HUAWEI Health Kit. |
HEALTHKIT_STRENGTH_READ | String | Views medium- and high-intensity data in HUAWEI Health Kit. |
HEALTHKIT_STRENGTH_WRITE | String | Stores medium- and high-intensity data in HUAWEI Health Kit. |
HEALTHKIT_BODYFAT_READ | String | Views the body fat data (such as body fat rate, BMI, muscle mass, moisture rate, visceral fat, bone salt, protein ratio, and skeletal muscle mass) in HUAWEI Health Kit. |
HEALTHKIT_BODYFAT_WRITE | String | Stores the body fat data (such as body fat rate, BMI, muscle mass, moisture rate, visceral fat, bone salt, protein ratio, and skeletal muscle mass) in HUAWEI Health Kit. |
HEALTHKIT_NUTRITION_READ | String | Views the nutrition data in HUAWEI Health Kit. |
HEALTHKIT_NUTRITION_WRITE | String | Stores the nutrition data in HUAWEI Health Kit. |
HEALTHKIT_BLOODPRESSURE_READ | String | Views the blood pressure data in HUAWEI Health Kit. |
HEALTHKIT_BLOODPRESSURE_WRITE | String | Stores the blood pressure data in HUAWEI Health Kit. |
HEALTHKIT_BODYTEMPERATURE_READ | String | Views the body temperature data in HUAWEI Health Kit. |
HEALTHKIT_BODYTEMPERATURE_WRITE | String | Stores the body temperature data in HUAWEI Health Kit. |
HEALTHKIT_OXYGENSTATURATION_READ | String | Views the blood oxygen data in HUAWEI Health Kit. |
HEALTHKIT_OXYGENSTATURATION_WRITE | String | Stores the blood oxygen data in HUAWEI Health Kit. |
HEALTHKIT_REPRODUCTIVE_READ | String | Views the reproductive data in HUAWEI Health Kit. |
HEALTHKIT_REPRODUCTIVE_WRITE | String | Stores the reproductive data in HUAWEI Health Kit. |
HEALTHKIT_ACTIVITY_RECORD_READ | String | Views the activity data (such as activity points, workout, strength, running posture, cycling, and activity duration) in HUAWEI Health Kit. |
HEALTHKIT_ACTIVITY_RECORD_WRITE | String | Stores the activity data (such as activity points, workout, strength, running posture, cycling, and activity duration) in HUAWEI Health Kit. |
HEALTHKIT_STRESS_READ | String | Views the stress data in HUAWEI Health Kit. |
HEALTHKIT_STRESS_WRITE | String | Stores the stress data in HUAWEI Health Kit. |
Method | Return Type | Description |
---|---|---|
getAllScopes | List<Scope> | Obtains all the scopes defined for the Health Kit. |
Obtains all the scopes defined for the Health Kit.
Type | Description |
---|---|
List<Scope> | List of all scopes. |
Data reading response class. Result classes are for utilizing the Health Kit API results. The summary of classes is described in the table below.
Name | Description |
---|---|
ReadReply | Data reading response class that defines the Read results of the DataController.read method. |
AuthHuaweiId | Result class that defines a HuaweiID for the HealthAuth.signIn method. |
Data reading response class that defines the Read results of the DataController.read method.
Name | Type | Description |
---|---|---|
groups | List<Group> | All data groups. |
sampleSets | List<SampleSet> | All sampling datasets. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Result class that defines a HuaweiID for the HealthAuth.signIn method.
Name | Type | Description |
---|---|---|
openId | String | OpenID. The value differs for the same user in different apps. The value is unique in a single app. |
photoUriString | String | Profile picture URI. |
accessToken | String | Access token. |
displayName | String | Nickname. |
status | int | User status. 1: normal, 2: Dbank suspended, 3: deregistered, 4: All services are suspended. |
gender | int | User gender. -1: unknown, 0: male, 1: female, 2: secret |
unionId | String | UnionID. The value is the same for the same user across all your apps. |
idToken | String | ID token from AppTouch ID information. |
expirationTimeSecs | int | Expiration time in seconds. |
givenName | String | Given name. |
familyName | String | Family name. |
grantedScopes | int | Authorized scopes. |
Method | Return Type | Description |
---|---|---|
toMap | Map<String, dynamic> | Returns a map representation of the object. |
toString | String | Returns a string representation of the object. |
Returns a map representation of the object.
Type | Description |
---|---|
Map<String, dynamic> | Map representation of the current object. |
Returns a string representation of the object.
Type | Description |
---|---|
String | String representation of the current object. |
Constants provided by the plugin. The summary of the constants are described in the table below. For other constant types please refer to the HUAWEI Health Kit Flutter Plugin document on the HUAWEI Developer website.
Name | Description |
---|---|
TimeUnit | Options for specifying the time unit. |
HiHealthStatusCodes | For error status codes you can refer to HiHealthStatusCodes. |
Options for specifying the time unit.
Value | Description |
---|---|
NANOSECONDS | Nanoseconds time unit. |
MICROSECONDS | Microseconds time unit. |
MILLISECONDS | Milliseconds time unit. |
SECONDS | Seconds time unit. |
MINUTES | Minutes time unit. |
HOURS | Hours time unit. |
DAYS | Days time unit. |
Before building a release version of your app you may need to customize the proguard-rules.pro obfuscation configuration file to prevent the HMS Core SDK from being obfuscated. Add the configurations below to exclude the HMS Core SDK from obfuscation. For more information on this topic refer to this Android developer guide.
<flutter_project>/android/app/proguard-rules.pro
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.hms.flutter.** { *; }
# Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-dontwarn io.flutter.embedding.**
<flutter_project>/android/app/build.gradle
buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
// Enables code shrinking, obfuscation and optimization for release builds
minifyEnabled true
// Unused resources will be removed, resources defined in the res/raw/keep.xml will be kept.
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
This plugin includes a demo project in the example folder, there you can find more usage examples.
In order to successfully run the demo application the HUAWEI ID Service and the Health Kit API should be authorized for your app as described in the Applying for HUAWEI ID Service and Applying for the HUAWEI Health Kit sections. The required Health Kit permission scopes for the demo application are as follows:
- Read/Write Body height and weight data
- Read/Write Step count data
- Read/Write Distance and floor change data
- Read/Write Speed data
- Read/Write Calories data
- Read/Write Activity data
- Read/Write Location data
- Read/Write Heart rate data
- Read/Write User activity records data
If you have questions about how to use HMS samples, try the following options:
- Stack Overflow is the best place for any programming questions. Be sure to tag your question with huawei-mobile-services.
- Github is the official repository for these plugins, You can open an issue or submit your ideas.
- Huawei Developer Forum HMS Core Module is great for general questions, or seeking recommendations and opinions.
- Huawei Developer Docs is place to official documentation for all HMS Core Kits, you can find detailed documentations in there.
If you run into a bug in our samples, please submit an issue to the GitHub repository.
Huawei Safety Detect Kit Flutter Plugin is licensed under Apache 2.0 license