Granularity

  • Granularity defines location granularity levels for use with FusedLocationProviderClient APIs.

  • Coarse locations obscure the user's exact position for privacy, and apps should be prepared to work with only coarse location access, especially from Android 12 onwards.

  • There are three defined granularity levels: GRANULARITY_COARSE, GRANULARITY_FINE, and GRANULARITY_PERMISSION_LEVEL.

public abstract @interfaceGranularity implementsAnnotation

Location granularity levels to be used with APIs withinFusedLocationProviderClient.

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_COARSEThe desired location granularity is always coarse, regardless of the client permission level.
int GRANULARITY_FINEThe desired location granularity is always fine, regardless of the client permission level.
int GRANULARITY_PERMISSION_LEVELThe desired location granularity should correspond to the client permission level.

Inherited Method Summary

From interface java.lang.annotation.Annotation
abstractClass<? extends Annotation>
annotationType()
abstract boolean
equals(Object arg0)
abstract int
hashCode()
abstractString
toString()

Constants

public static final intGRANULARITY_COARSE

The desired location granularity is always coarse, regardless of the client permission level. The client will be delivered coarse locations while it has the Manifest.permission.ACCESS_FINE_LOCATION or Manifest.permission.ACCESS_COARSE_LOCATION permission, and no location if it lacks either.

Constant Value:1

public static final intGRANULARITY_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 intGRANULARITY_PERMISSION_LEVEL

The desired location granularity should correspond to the client permission level. The client will be delivered fine locations while it has the Manifest.permission.ACCESS_FINE_LOCATION permission, coarse locations while it has only the Manifest.permission.ACCESS_COARSE_LOCATION permission, and no location if it lacks either.

Constant Value:0

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-10-31 UTC.