Granularity
Stay organized with collections
Save and categorize content based on your preferences.
Location granularity levels to be used with APIs within FusedLocationProviderClient
.
Coarse
locations
obfuscate the user's true position while still providing a less accurate view
of the user's location. For applications that do not require the user's exact fine location
(such as a weather app for example), use of coarse location is encouraged to protect the
user's privacy. In addition, from Android 12 onwards, the user may force any app to use
coarse location regardless of the application's preferences, so apps should always be
prepared to work correctly with only access to coarse location.
Constant Summary
int |
GRANULARITY_COARSE
|
The desired location granularity is always
coarse, regardless of the client permission level. |
int |
GRANULARITY_FINE
|
The desired location granularity is always fine,
regardless of the client permission level. |
int |
GRANULARITY_PERMISSION_LEVEL
|
The desired location granularity should
correspond to the client permission level. |
Inherited Method Summary
From interface java.lang.annotation.Annotation
Constants
public static final int
GRANULARITY_COARSE
public static final int
GRANULARITY_FINE
The desired location granularity is always fine, regardless of the client permission
level. The client will be delivered fine locations while it has the Manifest.permission.ACCESS_FINE_LOCATION
, and no location if it lacks that
permission.
Constant Value:
2
public static final int
GRANULARITY_PERMISSION_LEVEL
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eGranularity\u003c/code\u003e defines the level of location detail, impacting user privacy and app functionality.\u003c/p\u003e\n"],["\u003cp\u003eLocation granularity can be set to \u003ccode\u003eCOARSE\u003c/code\u003e, \u003ccode\u003eFINE\u003c/code\u003e, or \u003ccode\u003ePERMISSION_LEVEL\u003c/code\u003e, influencing the accuracy of location data provided.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eCOARSE\u003c/code\u003e granularity obfuscates the user's precise location, suitable for apps prioritizing privacy over accuracy.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eFINE\u003c/code\u003e granularity provides precise location data, requiring the \u003ccode\u003eACCESS_FINE_LOCATION\u003c/code\u003e permission and potentially impacting user privacy.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ePERMISSION_LEVEL\u003c/code\u003e granularity dynamically adjusts location detail based on granted permissions, balancing accuracy and privacy.\u003c/p\u003e\n"]]],["Granularity defines location accuracy levels for APIs within FusedLocationProviderClient. It offers three constants: `GRANULARITY_COARSE` (always coarse), `GRANULARITY_FINE` (always fine), and `GRANULARITY_PERMISSION_LEVEL` (matches permission). Coarse locations are encouraged for privacy and may be forced by users from Android 12 onwards. `GRANULARITY_COARSE` and `GRANULARITY_FINE` deliver set accuracy regardless of permission, while `GRANULARITY_PERMISSION_LEVEL` delivers location accuracy based on permission.\n"],null,["# Granularity\n\npublic abstract @interface **Granularity** implements [Annotation](//developer.android.com/reference/java/lang/annotation/Annotation.html) \nLocation granularity levels to be used with APIs within [FusedLocationProviderClient](/android/reference/com/google/android/gms/location/FusedLocationProviderClient).\n\n[Coarse\nlocations](//developer.android.com/training/location/permissions#accuracy) obfuscate the user's true position while still providing a less accurate view\nof the user's location. For applications that do not require the user's exact fine location\n(such as a weather app for example), use of coarse location is encouraged to protect the\nuser's privacy. In addition, from Android 12 onwards, the user may force any app to use\ncoarse location regardless of the application's preferences, so apps should always be\nprepared to work correctly with only access to coarse location. \n\n### Constant Summary\n\n|-----|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|\n| int | [GRANULARITY_COARSE](/android/reference/com/google/android/gms/location/Granularity#GRANULARITY_COARSE) | The desired location granularity is always coarse, regardless of the client permission level. |\n| int | [GRANULARITY_FINE](/android/reference/com/google/android/gms/location/Granularity#GRANULARITY_FINE) | The desired location granularity is always fine, regardless of the client permission level. |\n| int | [GRANULARITY_PERMISSION_LEVEL](/android/reference/com/google/android/gms/location/Granularity#GRANULARITY_PERMISSION_LEVEL) | The desired location granularity should correspond to the client permission level. |\n\n### Inherited Method Summary\n\nFrom interface java.lang.annotation.Annotation \n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| abstract [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c? extends [Annotation](//developer.android.com/reference/java/lang/annotation/Annotation.html)\\\u003e | annotationType() |\n| abstract boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| abstract int | hashCode() |\n| abstract [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n\nConstants\n---------\n\n#### public static final int\n**GRANULARITY_COARSE**\n\nThe desired location granularity is always coarse, regardless of the client\npermission level. The client will be delivered coarse locations while it has the\n[Manifest.permission.ACCESS_FINE_LOCATION](//developer.android.com/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION) or [Manifest.permission.ACCESS_COARSE_LOCATION](//developer.android.com/reference/android/Manifest.permission.html#ACCESS_COARSE_LOCATION) permission, and no location if it\nlacks either. \nConstant Value: 1 \n\n#### public static final int\n**GRANULARITY_FINE**\n\nThe desired location granularity is always fine, regardless of the client permission\nlevel. The client will be delivered fine locations while it has the [Manifest.permission.ACCESS_FINE_LOCATION](//developer.android.com/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION), and no location if it lacks that\npermission. \nConstant Value: 2 \n\n#### public static final int\n**GRANULARITY_PERMISSION_LEVEL**\n\nThe desired location granularity should correspond to the client permission level.\nThe client will be delivered fine locations while it has the [Manifest.permission.ACCESS_FINE_LOCATION](//developer.android.com/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION) permission, coarse locations while\nit has only the [Manifest.permission.ACCESS_COARSE_LOCATION](//developer.android.com/reference/android/Manifest.permission.html#ACCESS_COARSE_LOCATION) permission, and no location if it\nlacks either. \nConstant Value: 0"]]