ConfigApi
Stay organized with collections
Save and categorize content based on your preferences.
This interface is deprecated.
For reading and writing historical fitness data, use Health Connect
instead.
API for accessing custom data types and settings in Google Fit.
Custom data type
definitions can be added and then retrieved using createCustomDataType(GoogleApiClient, DataTypeCreateRequest)
and readDataType(GoogleApiClient, String)
.
disableFit(GoogleApiClient)
can be used to disconnect your app from Google
Fit.
The Config API should be accessed via the Fitness
entry
point. Example:
GoogleApiClient client = new GoogleApiClient.Builder(context)
.addApi(Fitness.CONFIG_API)
...
.build();
client.connect();
PendingResult<DataTypeResult> pendingResult = Fitness.ConfigApi.readDataType(
client, "com.example.my_custom_data_type");
DataTypeResult dataTypeResult = pendingResult.await();
DataType dataType = dataTypeResult.getDataType();
Public Methods
This method is deprecated.
Support for custom data types will be removed in a future version of Google Fit. Use one
of the pre-defined data types listed in DataType
.
Defines a new data type which is added to the Google Fit platform on behalf of the
current application. Useful for adding a private custom data type for recording
app-specific data. Custom data created by one app will not be visible to other
apps.
Example:
PendingResult<DataTypeResult> pendingResult =
ConfigApi.createCustomDataType(
client,
new DataTypeCreateRequest.Builder()
.setName(DATA_TYPE_NAME)
.addField(MY_FIELD1)
.addField(MY_FIELD2)
.build());
DataTypeResult result = pendingResult.await();
Parameters
Disables Google Fit for an app. Can be used to revoke all granted OAuth access
permissions from an app and consequently remove all existing subscriptions and
registrations of the app.
Parameters
client
An existing GoogleApiClient. Must be connected at the time of this call.
Returns
- Result containing the status of the request.
This method is deprecated.
Support for custom data types will be removed in a future version of Google Fit. Use one
of the pre-defined data types listed in DataType
.
Returns a data type with the specified dataTypeName
. Useful to retrieve
shareable data types added by other apps or custom data types added by your app. Custom
data types created by other apps will not be returned.
Parameters
Returns
- Result containing the status of the request.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eConfigApi\u003c/code\u003e is deprecated and developers should use Health Connect for historical fitness data.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for accessing custom data types and settings in Google Fit, although support for custom data types will be removed in the future.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edisableFit\u003c/code\u003e method can disconnect an app from Google Fit, revoking permissions and removing subscriptions/registrations.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers should utilize pre-defined data types listed in \u003ccode\u003eDataType\u003c/code\u003e instead of creating custom ones.\u003c/p\u003e\n"]]],["The ConfigApi, now deprecated, allowed access to custom data types and settings in Google Fit. Key actions included: creating custom data types via `createCustomDataType` (deprecated), retrieving them with `readDataType` (deprecated), and disconnecting an app from Google Fit using `disableFit`. Access was through the `Fitness` entry point with `GoogleApiClient`. Note that custom data type support will be removed in the future in favor of predefined data types. Health Connect is now used for reading and writing historical data.\n"],null,["# ConfigApi\n\npublic interface **ConfigApi** \n**This interface is deprecated.** \n\nFor reading and writing historical fitness data, use [Health Connect](//developer.android.com/guide/health-and-fitness/health-connect)\ninstead.\n\nAPI for accessing custom data types and settings in Google Fit.\n\nCustom [data type](/android/reference/com/google/android/gms/fitness/data/DataType)\ndefinitions can be added and then retrieved using [createCustomDataType(GoogleApiClient, DataTypeCreateRequest)](/android/reference/com/google/android/gms/fitness/ConfigApi#createCustomDataType(com.google.android.gms.common.api.GoogleApiClient,%20com.google.android.gms.fitness.request.DataTypeCreateRequest)) and [readDataType(GoogleApiClient, String)](/android/reference/com/google/android/gms/fitness/ConfigApi#readDataType(com.google.android.gms.common.api.GoogleApiClient,%20java.lang.String)).\n\n[disableFit(GoogleApiClient)](/android/reference/com/google/android/gms/fitness/ConfigApi#disableFit(com.google.android.gms.common.api.GoogleApiClient)) can be used to disconnect your app from Google\nFit.\n\nThe Config API should be accessed via the [Fitness](/android/reference/com/google/android/gms/fitness/Fitness) entry\npoint. Example: \n\n```\n GoogleApiClient client = new GoogleApiClient.Builder(context)\n .addApi(Fitness.CONFIG_API)\n ...\n .build();\n client.connect();\n\n PendingResult\u003cDataTypeResult\u003e pendingResult = Fitness.ConfigApi.readDataType(\n client, \"com.example.my_custom_data_type\");\n\n DataTypeResult dataTypeResult = pendingResult.await();\n DataType dataType = dataTypeResult.getDataType();\n \n``` \n\n### Public Method Summary\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [PendingResult](/android/reference/com/google/android/gms/common/api/PendingResult)\\\u003c[DataTypeResult](/android/reference/com/google/android/gms/fitness/result/DataTypeResult)\\\u003e | [createCustomDataType](/android/reference/com/google/android/gms/fitness/ConfigApi#createCustomDataType(com.google.android.gms.common.api.GoogleApiClient,%20com.google.android.gms.fitness.request.DataTypeCreateRequest))([GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) client, [DataTypeCreateRequest](/android/reference/com/google/android/gms/fitness/request/DataTypeCreateRequest) request) *This method is deprecated. Support for custom data types will be removed in a future version of Google Fit. Use one of the pre-defined data types listed in [DataType](/android/reference/com/google/android/gms/fitness/data/DataType).* |\n| abstract [PendingResult](/android/reference/com/google/android/gms/common/api/PendingResult)\\\u003c[Status](/android/reference/com/google/android/gms/common/api/Status)\\\u003e | [disableFit](/android/reference/com/google/android/gms/fitness/ConfigApi#disableFit(com.google.android.gms.common.api.GoogleApiClient))([GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) client) Disables Google Fit for an app. |\n| abstract [PendingResult](/android/reference/com/google/android/gms/common/api/PendingResult)\\\u003c[DataTypeResult](/android/reference/com/google/android/gms/fitness/result/DataTypeResult)\\\u003e | [readDataType](/android/reference/com/google/android/gms/fitness/ConfigApi#readDataType(com.google.android.gms.common.api.GoogleApiClient,%20java.lang.String))([GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) client, [String](//developer.android.com/reference/java/lang/String.html) dataTypeName) *This method is deprecated. Support for custom data types will be removed in a future version of Google Fit. Use one of the pre-defined data types listed in [DataType](/android/reference/com/google/android/gms/fitness/data/DataType).* |\n\nPublic Methods\n--------------\n\n#### public abstract [PendingResult](/android/reference/com/google/android/gms/common/api/PendingResult)\\\u003c[DataTypeResult](/android/reference/com/google/android/gms/fitness/result/DataTypeResult)\\\u003e\n**createCustomDataType** ([GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) client, [DataTypeCreateRequest](/android/reference/com/google/android/gms/fitness/request/DataTypeCreateRequest) request)\n\n**This method is deprecated.** \n\nSupport for custom data types will be removed in a future version of Google Fit. Use one\nof the pre-defined data types listed in [DataType](/android/reference/com/google/android/gms/fitness/data/DataType). \nDefines a new data type which is added to the Google Fit platform on behalf of the\ncurrent application. Useful for adding a private custom data type for recording\napp-specific data. Custom data created by one app will not be visible to other\napps.\n\nExample: \n\n```\n PendingResult\u003cDataTypeResult\u003e pendingResult =\n ConfigApi.createCustomDataType(\n client,\n new DataTypeCreateRequest.Builder()\n .setName(DATA_TYPE_NAME)\n .addField(MY_FIELD1)\n .addField(MY_FIELD2)\n .build());\n DataTypeResult result = pendingResult.await();\n \n``` \n\n##### Parameters\n\n| client | An existing GoogleApiClient. Must be connected at the time of this call. |\n| request | The new data type name and fields that need to be added. |\n|---------|--------------------------------------------------------------------------|\n\n##### Returns\n\n- A pending result containing the status of the request. If an existing data type has the same name but different fields, the operation will fail with [FitnessStatusCodes.CONFLICTING_DATA_TYPE](/android/reference/com/google/android/gms/fitness/FitnessStatusCodes#CONFLICTING_DATA_TYPE). If application package name does not match [DataType](/android/reference/com/google/android/gms/fitness/data/DataType)'s name, the operation will fail with [FitnessStatusCodes.INCONSISTENT_DATA_TYPE](/android/reference/com/google/android/gms/fitness/FitnessStatusCodes#INCONSISTENT_DATA_TYPE) status code. \n\n#### public abstract [PendingResult](/android/reference/com/google/android/gms/common/api/PendingResult)\\\u003c[Status](/android/reference/com/google/android/gms/common/api/Status)\\\u003e\n**disableFit** ([GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) client)\n\nDisables Google Fit for an app. Can be used to revoke all granted OAuth access\npermissions from an app and consequently remove all existing subscriptions and\nregistrations of the app. \n\n##### Parameters\n\n| client | An existing GoogleApiClient. Must be connected at the time of this call. |\n|--------|--------------------------------------------------------------------------|\n\n##### Returns\n\n- Result containing the status of the request. \n\n#### public abstract [PendingResult](/android/reference/com/google/android/gms/common/api/PendingResult)\\\u003c[DataTypeResult](/android/reference/com/google/android/gms/fitness/result/DataTypeResult)\\\u003e\n**readDataType** ([GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) client, [String](//developer.android.com/reference/java/lang/String.html) dataTypeName)\n\n**This method is deprecated.** \n\nSupport for custom data types will be removed in a future version of Google Fit. Use one\nof the pre-defined data types listed in [DataType](/android/reference/com/google/android/gms/fitness/data/DataType). \nReturns a data type with the specified `dataTypeName`. Useful to retrieve\nshareable data types added by other apps or custom data types added by your app. Custom\ndata types created by other apps will not be returned. \n\n##### Parameters\n\n| client | An existing GoogleApiClient. It does not need to be connected at the time of this call, but the read result will be delayed until the connection is complete. |\n| dataTypeName | Name of the data type we want to read. |\n|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- Result containing the status of the request."]]