バックグラウンド位置情報の制限
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 8.0(API レベル 26)は電力消費を抑えるため、アプリがバックグラウンドで実行されている間、アプリがユーザーの現在地を取得する回数を制限しています。このような状況では、アプリが位置情報の更新を受信できるのは 1 時間に数回だけです。
注: この制限は、アプリのターゲット SDK バージョンにかかわらず、Android 8.0(API レベル 26)以降を搭載するデバイスで使用されるすべてのアプリに適用されます。
アプリがバックグラウンドで実行されているときにリアルタイム アラートまたは動作検出機能を必要とする場合、この位置取得動作に留意することが特に重要になります。
フォアグラウンド アプリの動作が保持される
Android 8.0(API レベル 26)が実行されているデバイスでアプリがフォアグラウンドにある場合、位置情報のアップデートの動作は、Android 7.1.1(API レベル 25)以下での動作と同じです。
警告:アプリが長期間にわたりほぼリアルタイムで位置情報のアップデートを取得していると、デバイスの電池寿命が大幅に短くなります。
アプリの位置情報動作を調整する
アプリが位置情報のアップデートを受信する頻度が少ない場合は、バックグラウンドで実行されているアプリのユースケースが成功するかどうかを検討します。まったく成功しない場合は、次のいずれかのアクションを実行すると、位置情報のアップデートを取得する頻度を増やすことができます。
- アプリをフォアグラウンドで操作します。
-
startForegroundService()
を呼び出して、アプリでフォアグラウンド サービスを開始します。このようなフォアグラウンド サービスがアクティブの場合、アプリの通知エリアに進行中の通知が表示されます。
注意: Android 11(API レベル 30)以降を搭載したデバイスで、アプリがバックグラウンドで実行中にフォアグラウンド サービスを開始する場合、ユーザーがアプリに ACCESS_BACKGROUND_LOCATION
権限を付与していない限り、アプリは位置情報にアクセスできません。詳しくは、フォアグラウンド サービスに関連する使用中の制限に関するガイダンスをご覧ください。
-
消費電力量を最小限に抑えるように最適化されている Geofencing API の要素(
GeofencingClient
など)を使用します。
-
頻繁に位置情報のアップデートをリクエストしているフォアグラウンド アプリがある場合は、位置情報のアップデートをより速く受信できるパッシブな位置情報リスナーを使用します。
注: アプリからアップデートが頻繁な位置情報履歴にアクセスする必要がある場合は、FusedLocationProviderApi
インターフェースなど、融合された位置予測プロバイダ API 要素のバッチ バージョンを使用します。アプリがバックグラウンドで実行されていると、この API は非バッチ API よりも頻繁にユーザーの位置を受信します。ただし、1 時間に数回だけ、アプリが引き続きアップデートをバッチで受信することに注意してください。
影響を受ける API
バックグラウンド アプリの位置情報取得動作を変更すると、次の API に影響があります。
- Fused Location Provider(FLP)
-
- ジオフェンス
-
- バックグラウンド アプリは、融合された位置予測プロバイダからのアップデートよりも頻繁にジオフェンス遷移イベントを受信できます。
- ジオフェンス イベントに対する平均的な応答性は 2 ~ 3 分ごとです。
- GNSS Measurements と GNSS Navigation Message
-
- Location Manager
-
- Wi-Fi Manager
-
startScan()
メソッドがバックグラウンド アプリのフルスキャンを実行するのは、1 時間に 2 ~ 3 回だけです。バックグラウンド アプリでフルスキャンの直後にこのメソッドを再度呼び出した場合は、直前のスキャンでキャッシュされた結果が WifiManager
クラスから提供されます。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[null,null,["最終更新日 2025-07-27 UTC。"],[],[],null,["# Background Location Limits\n\nIn an effort to reduce power consumption, Android 8.0 (API level 26) limits\nhow frequently an app can retrieve the user's current location while the app is\n[running in the background](/guide/background). Under these\nconditions, apps can receive location updates only a few times each hour.\n\n**Note:** These limitations apply to all apps used on devices\nrunning Android 8.0 (API level 26) or higher, **regardless of an app's\ntarget SDK version**.\n\nThis location retrieval behavior is particularly\nimportant to keep in mind if your app relies on real-time alerts or motion\ndetection while running in the background.\n\nForeground app behavior is preserved\n------------------------------------\n\n\nIf an app is in the foreground on a device running Android 8.0 (API level 26),\nthe location update behavior is the same as on Android 7.1.1 (API level\n25) and lower.\n\n**Warning:** If your app retrieves near real-time location\nupdates over a long period of time, the device's battery life becomes\nsignificantly shorter.\n\nTuning your app's location behavior\n-----------------------------------\n\nConsider whether your app's use cases for running in the background cannot\nsucceed at all if your app receives infrequent location updates. If this is the\ncase, you can retrieve location updates more frequently by performing one of the\nfollowing actions:\n\n- Bring your app to the foreground.\n- Start a [foreground\n service](/guide/components/foreground-services) in your app by calling\n [startForegroundService()](/reference/android/content/Context#startForegroundService(android.content.Intent)). When such a foreground service is active, it\n appears as an ongoing notification in the\n [notification\n area](/guide/topics/ui/notifiers/notifications).\n\n **Caution:** If your app starts a foreground service\n while running in the background on a device that runs Android 11 (API\n level 30) or higher, your app cannot access location information unless the\n user has granted the\n [`ACCESS_BACKGROUND_LOCATION`](/reference/android/Manifest.permission#ACCESS_BACKGROUND_LOCATION)\n permission to your app. For more information, view the guidance about the\n [while-in-use\n restrictions](/guide/components/foreground-services#while-in-use-restrictions) that are associated with foreground services.\n- Use elements of the Geofencing API, such as the [`GeofencingClient`](https://developers.google.com/android/reference/com/google/android/gms/location/GeofencingClient), which are optimized for minimizing power use.\n- Use a passive location listener, which may receive faster location updates if there are foreground apps requesting location updates at a faster rate.\n\n**Note:** If your app needs access to location history that\ncontains time-frequent updates, use the batched version of the Fused Location\nProvider API elements, such as the\n[`FusedLocationProviderApi`](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderApi)\ninterface. When your app is running in the background, this API receives the\nuser's location more frequently than the non-batched API. Keep in mind, however,\nthat your app still receives updates in batches only a few times each hour.\n\nAffected APIs\n-------------\n\n\nThe changes to location retrieval behavior in background apps affect the\nfollowing APIs:\n\n[Fused\nLocation Provider (FLP)](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderApi)\n:\n - If your app is running in the background, the location system service\n computes a new location for your app only a few times each hour. This\n is the case even when your app is requesting more frequent location\n updates.\n\n By using the\n [batched version](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#setMaxWaitTime(long)) of FLP, however, you have access to more\n time-frequent location history after your app receives a batch update,\n which also occurs only a few times each hour.\n - If your app is running in the foreground, there is no change in location sampling rates compared to Android 7.1.1 (API level 25).\n\nGeofencing\n:\n - Background apps can receive geofencing transition events more frequently than updates from the Fused Location Provider.\n - The average responsiveness for a geofencing event is every couple of minutes or so.\n\nGNSS Measurements and GNSS Navigation Messages\n:\n - When your app is in the background, callbacks that are registered to receive outputs from [GnssMeasurement](/reference/android/location/GnssMeasurement) and [GnssNavigationMessage](/reference/android/location/GnssNavigationMessage) stop executing.\n\nLocation Manager\n:\n - Location updates are provided to background apps only a few times\n each hour.\n\n\n **Note:** If your app is running on a device with\n Google Play services installed, it is highly recommended that you use\n the [Fused\n Location Provider (FLP)](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderApi) instead.\n\nWi-Fi Manager\n:\n The [startScan()](/reference/android/net/wifi/WifiManager#startScan()) method\n performs a full scan for background apps only a few times each hour. If a\n background app calls the method again soon afterward, the\n [WifiManager](/reference/android/net/wifi/WifiManager) class provides cached results from the\n previous scan."]]