2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
位置情報の 3 段階の利用許可
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 10 では、アプリによるデバイスの位置情報へのアクセスを 3 段階で管理できます。
Android 9 以前では、アプリによる位置情報へのアクセスをいったん許可または拒否すると、その選択が固定化されていました。選択できるオプションは拒否または許可で、許可を選択した場合はアプリが常に(フォアグラウンドとバックグラウンドで)アクセスできるようになっていました。Android 10 には位置情報の 3 段階のアクセス許可が導入され、デバイスの位置情報にアクセスしようとするアプリに対して 3 つのオプションを与えることができます。ユーザーは権限レベルを選ぶか拒否するよう促されます。
通常、ユーザーのデバイスには図 1 のような 3 つのオプションが表示されます。ただし、2 つのオプションだけとなるユースケースもあり、その場合は 2 つしか表示されません。
図 1. 3 段階の通知画面
次の 3 つのオプションがあります。
- 常に許可: アプリが使用中ではない場合(バックグラウンドで実行中)でも、デバイスの現在地がアプリに認識されます。これは Android 9 以前の権限と同じです。
- アプリが使用中の場合のみ許可: デバイスが位置情報を認識できるのは、アプリがアクティブに実行されている場合のみです。
- 許可しない: デバイスの位置情報をアプリは認識できません。これは、Android 9 以前のアクセスの拒否と同じです。
アプリが権限をリクエストすると、ユーザーは位置情報へのアクセスを許可するよう求められます。
ユーザーが [アプリの使用中のみ許可] を選択した場合、アプリがさらに [常に許可] をリクエストすることがあります。ユーザーのデバイスにリクエスト ダイアログが表示されます(図 2 に示します)。ユーザーが [使用中のアクセスの維持] を選択した場合、次にアプリがデバイスの位置情報にアクセスする際は [次回から表示しない] というオプションが表示されます。
Android 10 をターゲットとするアプリが次のような状況の場合、ダイアログが表示されます。
- アクセスが許可されてから 24 時間が経過した。
- アプリがバックグラウンドでのみ位置情報を受信している。
- 画面がオンの状態で、ユーザーが別のアプリを利用していない。
図 2. 段階的なアクセス許可
権限のリクエストに関する詳細については、アプリによるデバイスの位置情報へのアクセスをご覧ください。Android 9 以前を対象とするアプリの場合は、ユーザー開始型アクションの継続をご覧ください。
影響
Android 10 の場合、バックグラウンドでデバイスの位置情報アクセスが必要なアプリは、位置情報の 3 段階のアクセス許可機能の対象となります。
アプリのコードは変更できますが、許可に関連するフレームワークの動作を変更またはカスタマイズすることはできません。
実装
位置情報の 3 段階のアクセス許可は、アプリのターゲット SDK に関係なく、Android 10 のアプリに適用されます。
アプリの使用例の実装(アップグレード時)については、デベロッパー向けドキュメントのデバイス アップグレード シナリオの設計セクションをご覧ください。
さまざまなユースケース(Google マップや Google Play 開発者サービスのように、アプリがバックグラウンドでの位置情報へのアクセスが必要な場合など)に対してアクセスを可能にする方法について、アプリによるデバイスの位置情報へのアクセスに関するページで以下のトピックをご覧ください。
アプリ内での位置情報へのアクセス
ユーザーは、必要に応じて、アプリのアクセス許可を [許可しない] または [アプリの使用中のみ許可] に変更できます。アプリ内での位置情報へのアクセス許可およびすべてのファースト パーティ アプリとサードパーティ アプリに対して、次の表に示すように、ユーザー コントロール レベルを提供してください。
アプリがリクエストする必要がある権限タイプ |
提供するユーザー オプション |
アプリがフォアグラウンドでの権限のみをリクエスト |
アプリの使用中のみ許可
拒否
|
アプリが常に権限をリクエスト(フォアグラウンドとバックグラウンド)
|
常に許可
アプリの使用中のみ許可
拒否
|
位置情報へのアクセス リクエストを行うすべてのアプリ
|
アプリの使用中のみ許可
|
これらの権限は、すべての位置情報リクエストに適用されます。アプリの使用中のみ許可の権限を持つアプリには、バックグラウンドでのスキャン(Wi-Fi、モバイル)が許可されません。
Android 11 以前では、アプリの使用中のみ許可の権限を持つアプリには、バックグラウンドでの Bluetooth スキャンが許可されません。Android 12 以降では、アプリの使用中のみ許可の権限を持つアプリは、neverForLocation
属性の値に android:usesPermissionFlags
を設定することで、Bluetooth スキャンの結果を取得できます。詳しくは、アプリが物理的な位置情報を取得しない場合をご覧ください。
OS のアップグレード
Android 10 への OS のアップグレードを行うと、アプリの位置情報の権限が次のように変更されます。
- オンは、使用中のみ許可になります。
- オフは、オフ(拒否)のままとなります。
- 事前に付与された位置情報へのアクセス権限は、使用中のみ許可に対する事前の付与となります。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","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-07-27 UTC。"],[],[],null,["# Tristate location permissions in Android 10 give users more control over\nhow apps access their device locations.\n\nIn Android 9 and lower, users made persistent choices when granting location access to apps. They\ncould either **Deny** or **Allow**, the latter of which gave apps access\nall the time (foreground and background). Tristate location permissions in Android 10 give users three options for allowing an app access to a device's location.\nUsers are prompted to grant or deny the permission level when an app requests it.\n\nA user normally sees the three choices presented in Figure 1. However, there are use cases where\nonly two of these options are required, and in such cases only those two are shown.\n\n**Figure 1.** Tristate notifications screen.\n\nThese are the three options:\n\n- **Allow all the time**: the device's location is known to the app even when the app is not in use (running in the background). This is equivalent to allowing permission in Android 9 and lower.\n- **Allow only while the app is in use**: (foreground only) the device's location is only visible to the app when it's actively running.\n- **Deny**: the device's location is never visible to the app. This is the same as denying permission in Android 9 and lower.\n\nUsers are prompted to grant location access permission when apps request the\npermission.\n\nOnce a user grants **Allow only while the app is in use** access permission, an app\ncan request an incremental increase in access to **Allow all the time** . The user sees\na request dialog (shown in [Figure 2](#incremental-permissions-screens)). If the user\nselects **Keep while-in-use access** , when the app accesses device location on next\nuse, the dialog provides the option to **Keep and don't ask again**.\n\nThe dialog appears under these conditions for apps targeting Android 10:\n\n- After at least 24 hours of granting the permission.\n- Only if the app is receiving locations in the background.\n- When the screen is on, and the user is not utilizing another app.\n\n**Figure 2.** Incremental permissions.\n\nTo learn more about requesting permissions, see [App access to\ndevice location](https://developer.android.com/training/location/request-updates). For details if your app targets Android 9 and lower, see [Continuation of user-initiated action](https://developer.android.com/training/location/request-updates).\n\nImpact\n------\n\nThe tristate location permissions feature affects any app that needs device location access\nwhile running in the background, and is required in Android 10.\n\nYou may change your code but you *may not* alter or customize\npermission-related behavior in the framework.\n\nImplementation\n--------------\n\nTristate location permissions are applied to apps in Android 10\nirrespective of an app's target SDK.\n\nFor information on implementing your app's use cases (on upgrades), refer to the [Design for device upgrade scenarios](https://developer.android.com/training/location/request-updates) section in the developer documentation.\n\nTo see how to enable access for different use cases (such as requiring background location\naccess for apps like Google Maps or Google Play services), view these topics on the [App access to\ndevice location](https://developer.android.com/training/location/request-updates) page:\n\n- [Request background\n location](https://developer.android.com/training/location/request-updates)\n- [Periodic checks of\n a device's location](https://developer.android.com/training/location/request-updates)\n\n### In-app location access\n\nUsers can change your app's access permissions to either **Deny** or **Allow\nonly while using the app** if they choose. For in-app location access permission, and for all\nfirst-party and third-party apps, provide the levels of user control given in the following table.\n\n| Permission type app needs to request | User options to provide |\n|------------------------------------------------------------|--------------------------------------------------------|\n| App requests foreground permissions only | Allow only while using the app Deny |\n| App requests permission always (foreground and background) | Allow all the time Allow only while using the app Deny |\n| All apps with location access requests | Allow only while using the app |\n\nThese permissions apply to all location requests. Apps with **Allow\nonly while using the app** permissions aren't allowed background Wi-Fi or\ncell scans.\n\nOn Android 11 or lower, apps with **Allow\nonly while using the app** permissions aren't allowed background\nBluetooth scans. From Android 12, apps with\n**Allow only while using the app** permissions can gain Bluetooth\nscan results by setting the value of the\n`android:usesPermissionFlags` attribute to\n`neverForLocation`. For more details, see\n[App\ndoesn't derive physical location](https://developer.android.com/about/versions/12/features/bluetooth-permissions#not-derive-physical-location).\n\nOS upgrades\n-----------\n\nOn an OS upgrade to Android 10, app location permissions translate\naccording to the following:\n\n- **On** becomes **Allow only while in Use**.\n- **Off** remains off (**Deny**).\n- Pre-granted location access becomes the **Allow only while in use** pre-grant."]]