[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Request location permissions\n\nTo protect user privacy, apps that use location services must request location\npermissions.\n\nMultiple permissions are related to location. Which permissions you request,\nand how you request them,\ndepend on the location requirements for your app's use case.\n\nThis page describes the different types of location requirements and explains\nhow to request location permissions in each case.\n\nTo request location permissions, follow the best practices for all\n[runtime permissions](/training/permissions/requesting).\n\nTypes of location access\n------------------------\n\nEach permission has a combination of the following characteristics:\n\n- **Category** : Either [foreground location](#foreground) or [background location](/develop/sensors-and-location/location/permissions/background).\n- **[Accuracy](#accuracy)**: Either precise location or approximate location.\n\n### Foreground location\n\nIf your app contains a feature that shares or receives location information only\nonce, or for a defined amount of time, then that feature requires foreground\nlocation access. Some examples include the following:\n\n- Within a navigation app, a feature allows users to get turn-by-turn directions.\n- Within a messaging app, a feature allows users to share their current location with another user.\n\nThe system considers your app to be using foreground location if a feature of\nyour app accesses the device's current location in one of the following\nsituations:\n\n- An activity that belongs to your app is visible.\n- Your app is running a foreground service. When a foreground service is\n running, the system raises user awareness by showing a persistent\n notification. Your app retains access when it's placed in the background,\n such as when the user presses the **Home** button on their device or turns\n their device's display off.\n\n Additionally, you should declare a [foreground service type](/guide/topics/manifest/service-element#foregroundservicetype) of\n `location`, as shown in the following code snippet. On Android\n 10 (API level 29) and higher, you must declare this foreground service type. \n\n \u003c!-- Recommended for Android 9 (API level 28) and lower. --\u003e\n \u003c!-- Required for Android 10 (API level 29) and higher. --\u003e\n \u003cservice\n android:name=\"MyNavigationService\"\n android:foregroundServiceType=\"location\" ... \u003e\n \u003c!-- Any inner elements would go here. --\u003e\n \u003c/service\u003e\n\nYou declare a need for foreground location when your app requests either the\n[`ACCESS_COARSE_LOCATION`](/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION) permission or the [`ACCESS_FINE_LOCATION`](/reference/android/Manifest.permission#ACCESS_FINE_LOCATION)\npermission, as shown in the following snippet: \n\n \u003cmanifest ... \u003e\n \u003c!-- Always include this permission --\u003e\n \u003cuses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" /\u003e\n\n \u003c!-- Include only if your app benefits from precise location access. --\u003e\n \u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /\u003e\n \u003c/manifest\u003e\n\n| **Note:** Beginning with Android 12, your app can call [`getLocationPowerSaverMode()`](/reference/android/os/PowerManager#getLocationPowerSaveMode()) to check how the device's location features behave when Battery Saver is active. If this returns [`LOCATION_MODE_FOREGROUND_ONLY`](/reference/android/os/PowerManager#LOCATION_MODE_FOREGROUND_ONLY), your app will continue to receive location updates while in the foreground or running a foreground service when Battery Saver is on, even if the screen is off.\n\n### Background location\n\nAn app requires background location access if a feature within the app\nconstantly shares location with other users or uses the [Geofencing API](/training/location/geofencing).\nSeveral examples include the following:\n\n- Within a family location sharing app, a feature allows users to continuously share location with family members.\n- Within an IoT app, a feature allows users to configure their home devices such that they turn off when the user leaves their home and turn back on when the user returns home.\n\nThe system considers your app to be using background location if it accesses the\ndevice's current location in any situation other than the ones described in the\n[foreground location](#foreground) section. The background location precision is the same\nas the [foreground location precision](#accuracy), which depends on the location\npermissions that your app declares.\n\nOn Android 10 (API level 29) and higher, you must declare the\n[`ACCESS_BACKGROUND_LOCATION`](/reference/android/Manifest.permission#ACCESS_BACKGROUND_LOCATION) permission in your app's manifest in order to\n[request background location access](/develop/sensors-and-location/location/permissions/background) at runtime. On earlier versions of\nAndroid, when your app receives foreground location access, it automatically\nreceives background location access as well. \n\n \u003cmanifest ... \u003e\n \u003c!-- Required only when requesting background location access on\n Android 10 (API level 29) and higher. --\u003e\n \u003cuses-permission android:name=\"android.permission.ACCESS_BACKGROUND_LOCATION\" /\u003e\n \u003c/manifest\u003e\n\n| **Note:** The Google Play Store has a [location policy](https://support.google.com/googleplay/android-developer/answer/9799150) concerning device location, restricting background location access to apps that need it for their core features and meet related policy requirements.\n\n### Accuracy\n\nAndroid supports the following levels of location accuracy:\n\nApproximate\n: Provides a device location estimate. If this location estimate is\n from the `LocationManagerService` or [`FusedLocationProvider`](https://developers.google.com/location-context/fused-location-provider), this\n estimate is accurate to within about 3 square kilometers (about 1.2 square\n miles). Your app can receive locations at this level of accuracy when you\n declare the `ACCESS_COARSE_LOCATION` permission but not the\n `ACCESS_FINE_LOCATION` permission.\n\nPrecise\n: Provides a device location estimate that is as accurate as possible.\n If the location estimate is from `LocationManagerService` or\n `FusedLocationProvider`, this estimate is usually within about 50 meters\n (160 feet) and is sometimes as accurate as within a few meters (10 feet) or\n better. Your app can receive locations at this level of accuracy when you\n declare the `ACCESS_FINE_LOCATION` permission.\n\nIf the [user grants the approximate location permission](/develop/sensors-and-location/location/permissions/runtime#approximate-request), your app only has\naccess to approximate location, regardless of which location permissions your\napp declares.\n\nYour app should still work when the user grants only approximate location\naccess. If a feature in your app absolutely requires access to precise location\nusing the `ACCESS_FINE_LOCATION` permission, you can ask the user to [allow your\napp to access precise location](/develop/sensors-and-location/location/permissions/runtime#upgrade-to-precise).\n\n### Reminder of background location grant\n\nOn Android 10 (API level 29) and higher, when a feature in your app accesses\ndevice location in the background for the first time after the user grants\nbackground location access, the system schedules a notification to send to the\nuser. This notification reminds the user that they've allowed your app to access\ndevice location all the time. An example notification appears in figure 8.\n\nCheck for location requirements in your app's SDK dependencies\n--------------------------------------------------------------\n\nCheck whether your app uses any SDKs that depend on location permissions,\nespecially the `ACCESS_FINE_LOCATION` permission. Read the [Getting to know the\nbehaviors of your SDK dependencies](https://medium.com/androiddevelopers/getting-to-know-the-behaviors-of-your-sdk-dependencies-f3dfed07a311) blog post on Medium for\nmore.\n\nAdditional resources\n--------------------\n\nFor more information about location permissions in Android, view the following\nmaterials:\n\n### Codelabs\n\n- [Privacy best practices](/codelabs/android-privacy-codelab)\n\n### Videos\n\n- [How to find possible background location usage](https://www.youtube.com/watch?v=xTVeFJZQ28c)\n\n### Samples\n\n- [Sample app](https://github.com/android/platform-samples/tree/main/samples/location/src/main/java/com/example/platform/location/permission) to demonstrate the use of location permissions."]]