ユーザーのオンボーディングを計画する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
多くのアプリには機能の説明やユーザーの同意の確認など、カスタムのオンボーディング フローがあります。ヘルスコネクトでオンボーディング フローを開始できるようにするには、マニフェストに次の行を追加します。
<!-- Required to support pre-Android 14 devices with APK Health Connect -->
<activity
android:name=".OnboardingActivity"
android:exported="true"
android:permission="com.google.android.apps.healthdata.permission.START_ONBOARDING">
<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_ONBOARDING"/>
</intent-filter>
</activity>
<!-- Required to support Android 14+ devices with platform Health Connect -->
<activity-alias
android:name="UAndAboveOnboardingActivity"
android:exported="true"
android:targetActivity=".OnboardingActivity"
android:permission="android.permission.health.START_ONBOARDING">
<intent-filter>
<action android:name="android.health.connect.action.SHOW_ONBOARDING" />
</intent-filter>
</activity-alias>
ユーザーは、アプリ内ではなくヘルスコネクト アプリから直接アプリへの接続を開始する場合があります。アプリでデータの読み取りまたは書き込みの権限を付与する以外の操作が必要な場合は、オンボーディング アクティビティを提供してください。
バージョン サポート
Android 14 以前のデバイスと Android 14 以降のデバイスの両方をサポートするには:
エクスポートされたアクティビティの要件
ユーザーがアプリをヘルスコネクトに接続しようとすると、エクスポートされたアクティビティが起動されます。このアクティビティで次のことを行う必要があります。
- 書き込みまたは読み取り対象のデータに関する説明など、関連するユーザー向け情報を表示します。
- 必要な場合はユーザーに同意を求めます。
- ヘルスコネクトへの権限のリクエストを行います。
- 定期的なワーカーのスケジュール設定など、その他のアプリ固有のロジックを実行します。
- 完了後、ユーザーがアクティビティを閉じられるようにします。
オンボーディング アクティビティをエクスポートしていないアプリの場合、ユーザーがアプリを接続しようとするとヘルスコネクトが [権限の管理] 画面を表示します。アプリの前提条件として、権限さえ付与されていれば統合が機能する場合には、これで問題ありません。
オンボーディング アクティビティは、複数回起動される場合があります。後でユーザーがアプリの権限を取り消して、再度接続した場合などが該当します。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[null,null,["最終更新日 2025-07-27 UTC。"],[],[],null,["# Plan for onboarding users\n\nMany apps have a custom onboarding flow such as feature education or asking user\nconsent. To enable Health Connect to launch your onboarding flow, add the\nfollowing to your manifest: \n\n \u003c!-- Required to support pre-Android 14 devices with APK Health Connect --\u003e\n \u003cactivity\n android:name=\".OnboardingActivity\"\n android:exported=\"true\"\n android:permission=\"com.google.android.apps.healthdata.permission.START_ONBOARDING\"\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"androidx.health.ACTION_SHOW_ONBOARDING\"/\u003e\n \u003c/intent-filter\u003e\n \u003c/activity\u003e\n \u003c!-- Required to support Android 14+ devices with platform Health Connect --\u003e\n \u003cactivity-alias\n android:name=\"UAndAboveOnboardingActivity\"\n android:exported=\"true\"\n android:targetActivity=\".OnboardingActivity\"\n android:permission=\"android.permission.health.START_ONBOARDING\"\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"android.health.connect.action.SHOW_ONBOARDING\" /\u003e\n \u003c/intent-filter\u003e\n \u003c/activity-alias\u003e\n\nUsers may initiate the connection to your app directly from the Health\nConnect app, rather than from within your app. If your app requires any\nadditional interaction beyond being granted permission to read or write data,\nprovide an onboarding activity.\n\nVersion support\n---------------\n\nTo support both pre-Android 14 and Android 14+ devices:\n\n- **Recommended approach:** Create a single onboarding activity that handles\n both scenarios. Use an activity alias, as shown in the example,to verify\n compatibility across Android versions.\n\n- **Alternative approach:** Export two separate activities,\n one for each Android version. This approach may lead to increased maintenance\n complexity.\n\nExported activity requirements\n------------------------------\n\nWhen a user attempts to connect your app to Health Connect, the exported\nactivity is launched. This activity must do the following:\n\n- Display any relevant user education such as explaining what data is written or read.\n- Ask the user to grant consent if required.\n- Make a permissions request to Health Connect.\n- Carry out any other application specific logic such as scheduling a periodic worker.\n- Once complete, allow the user to dismiss the activity.\n\nFor apps that *don't* export an onboarding activity, Health Connect instead\nbrings the user to the **Manage permissions** screen once the user attempts to\nconnect the app. This may be acceptable for apps where permissions being\ngranted is the only prerequisite for the integration to function.\n\nNote that the onboarding activity may be launched more than once, for example if\nthe user later revokes permissions to your app and then reconnects it."]]