앱에 액세스 권한이 있는 데이터 유형은 승인 범위에 해당합니다. 이러한 권한을 요청하려면 FitnessOptions 인스턴스에서 앱에 액세스해야 하는 데이터 유형을 추가해야 합니다. 앱에서 Google 피트니스 데이터 유형을 사용하도록 요청하면 Android SDK는 자동으로 해당 유형이 속한 범위를 확인하고 사용자에게 해당 범위에 대한 승인을 요청합니다.
API 클라이언트 만들기
API 클라이언트를 만들고 데이터를 쓰거나 읽기 위해 앱에서 액세스해야 하는 데이터 유형을 추가합니다. 다음 엔드포인트를 사용할 수 있습니다.
SensorsClient: 로컬 기기 및 호환 기기의 하드웨어 센서에서 다양한 건강 및 웰빙 데이터 소스에 액세스합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-17(UTC)"],[[["\u003cp\u003eThis guide provides instructions for Android developers to integrate Google Fit into their applications.\u003c/p\u003e\n"],["\u003cp\u003eIt outlines the necessary setup steps, including obtaining a Google account, setting up Google Play services, and acquiring OAuth 2.0 client ID.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers are guided through the process of creating an API client and implementing data access functionalities.\u003c/p\u003e\n"],["\u003cp\u003eBefore publishing, developers need to apply for verification to ensure data security and compliance.\u003c/p\u003e\n"],["\u003cp\u003eThe guide also explains the authorization flow users will experience when granting data access permissions to the app.\u003c/p\u003e\n"]]],[],null,["This guide explains how to start development with Google Fit on Android.\n| **Note:** Google Fit is part of Google Play services. [Learn about the\n| benefits your app gets from using Google Play\n| Services](/android/guides/overview).\n\nSetup\n\nBefore you start to build your app, complete the steps in the following\nsections.\n\nGet a Google Account\n\nTo use the Google Fit APIs, you need a Google Account. You can [create a new account](https://www.google.com/accounts/NewAccount) or\nuse an existing account. You might want to create a separate account to test your app from a user's perspective.\n\nGet Google Play services\n\nGet the latest client library for Google Play services on your development\nhost:\n\n1. Open the [Android SDK Manager](https://developer.android.com/studio/intro/update#sdk-manager).\n2. Under **SDK Tools** , find **Google Play services**.\n3. If the status for these packages isn't *Installed* , select them both and click **Install Packages**.\n\nGet an OAuth 2.0 client ID\n\nTo enable the Fitness API, [get an OAuth 2.0 client ID](/fit/android/get-api-key).\n\nCreate and configure your project\n\nWe recommend using the [Android Studio development environment](https://developer.android.com/studio) to build an app with the Fitness API. For\ndetails on how to make a new project and configure it in Android Studio, see\n[Create a project](https://developer.android.com/studio/projects/create-project).\n\nAdd the Google Play services client library\n\nIn Android Studio, open the `build.gradle` file for your module and add the Google Play services client library as a dependency: \n\nKotlin DSL \n\n```kotlin\nplugin {\n id(\"com.android.application\")\n}\n\n...\n\ndependencies {\n implementation(\"com.google.android.gms:play-services-fitness:21.2.0\")\n implementation(\"com.google.android.gms:play-services-auth:21.3.0\")\n}\n```\n\nGroovy DSL \n\n```carbon\napply plugin: 'com.android.application'\n\n...\n\ndependencies {\n implementation 'com.google.android.gms:play-services-fitness:21.2.0'\n implementation 'com.google.android.gms:play-services-auth:21.3.0'\n}\n```\n\nThis makes sure that Gradle automatically downloads the fitness SDK when it\nbuilds your app.\n\nBuild and test your app\n\nAfter you finish the setup steps, you can start to build your app. To get\nstarted, learn about the [types of data](/fit/datatypes) your app can [store and\nread](/fit/datatypes#using_data_types). Learn more about [working with\ndata](/fit/android/history) in Google Fit.\n\nGet the necessary Android permissions\n\nTo read and write [some types of data](/fit/android/authorization#data_types_that_ne\ned_android_permissions), your app needs to [request Android permissions](/fit/android/authorization#android_permission\ns).\n\nGet OAuth permissions\n\nThe data types that your app has permission to access correspond to\n[authorization scopes](/fit/datatypes#authorization_scopes). To ask\nfor these permissions, you need to [add\nwhich data types your app needs access to in a `FitnessOptions`\ninstance](/fit/android/api-client-example). When your app asks to use any of the Google Fit data\ntypes, the Android SDK automatically checks which scopes they belong to and asks\nthe user for authorization to those scopes.\n\nCreate an API client\n\nCreate an API client and add the data types that your app needs to access to\nwrite or read data. The following endpoints are available:\n\n- [`SensorsClient`](/android/reference/com/google/android/gms/fitness/SensorsClient): Access different sources of health and wellness data from hardware sensors in the local device and in companion devices.\n- [`RecordingClient`](/android/reference/com/google/android/gms/fitness/RecordingClient): For low-power, always-on background collection of sensor data.\n- [`HistoryClient`](/android/reference/com/google/android/gms/fitness/HistoryClient): Insert, delete, and read historical data in Google Fit.\n- [`SessionsClient`](/android/reference/com/google/android/gms/fitness/SessionsClient): Create and manage [Sessions](/fit/sessions) of user activity.\n- [`GoalsClient`](/android/reference/com/google/android/gms/fitness/GoalsClient): Read Heart Point and Steps goals created by users in Google Fit.\n- [`ConfigClient`](/android/reference/com/google/android/gms/fitness/ConfigClient): Access custom data types and settings in the Google Fit platform.\n\n[See an example of how to build a Fitness API client.](/fit/android/api-client-example)\n\nResulting user authorization flow\n\nThe following shows the resulting authorization flow that users experience\nwhen they're asked for permissions:\n**Figure 1.**The authorization flow for users.\n\n1. **Android permissions**: Users see what Android permissions your app has requested before downloading it. After your app is downloaded, it requests any runtime permissions that it needs, and users grant or deny these permissions.\n2. **Check and connect**: Your app checks whether permissions were granted before it requests access to other data types.\n3. **OAuth scopes request**: Google prompts the user to grant your app the OAuth scopes needed for the data types that it wants to access.\n4. **Access applied**: After the user grants permissions, your app can access the data types that belong to the scopes that the user has granted permission for.\n\nApply for verification\n\nAfter you build and test your app, you need to [apply for\nverification](/fit/verification) with different\nlevels of justification needed for\n[sensitive and restricted scopes](/fit/datatypes#authorization_scopes)."]]