LocationSettingsStates
Stay organized with collections
Save and categorize content based on your preferences.
Stores the current states of all location-related settings.
Inherited Constant Summary
From interface android.os.Parcelable
int |
CONTENTS_FILE_DESCRIPTOR |
|
int |
PARCELABLE_WRITE_RETURN_VALUE |
|
Public Method Summary
static LocationSettingsStates
|
fromIntent( Intent
intent)
Retrieves the location settings states from the intent extras.
|
boolean |
|
boolean |
isBleUsable()
Whether BLE is enabled and is usable by the app.
|
boolean |
isGpsPresent()
Whether GPS provider is present on the device.
|
boolean |
isGpsUsable()
Whether GPS provider is enabled and is usable by the app.
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
From interface android.os.Parcelable
abstract int |
describeContents()
|
abstract void |
writeToParcel( Parcel arg0,
int arg1)
|
Public Methods
Retrieves the location settings states from the intent extras. When the location
settings dialog finishes, you can use this method to retrieve the current location
settings states from the intent in your
Activity.onActivityResult(int, int, Intent)
;
public boolean isBlePresent ()
Whether BLE is present on the device.
public boolean isBleUsable ()
Whether BLE is enabled and is usable by the app.
public boolean isGpsPresent ()
Whether GPS provider is present on the device.
public boolean isGpsUsable ()
Whether GPS provider is enabled and is usable by the app.
public boolean isLocationPresent ()
Whether location is present on the device.
This method returns true when either GPS or network location provider is
present.
public boolean isLocationUsable ()
Whether location is enabled and is usable by the app.
This method returns true when either GPS or network location provider is usable.
public boolean isNetworkLocationPresent ()
Whether network location provider is present on the device.
public boolean isNetworkLocationUsable ()
Whether network location provider is enabled and usable by the app.
public void writeToParcel (Parcel dest, int
flags)
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\u003eLocationSettingsStates\u003c/code\u003e stores the current state of all location-related settings on an Android device, such as GPS, network location, and Bluetooth Low Energy (BLE).\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to check the presence and usability of these location providers, like \u003ccode\u003eisGpsPresent()\u003c/code\u003e, \u003ccode\u003eisGpsUsable()\u003c/code\u003e, \u003ccode\u003eisNetworkLocationPresent()\u003c/code\u003e, and so on.\u003c/p\u003e\n"],["\u003cp\u003eYou can obtain an instance of \u003ccode\u003eLocationSettingsStates\u003c/code\u003e from an Intent received in \u003ccode\u003eonActivityResult\u003c/code\u003e after the location settings dialog is closed, using \u003ccode\u003efromIntent()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis class implements \u003ccode\u003eParcelable\u003c/code\u003e, enabling it to be passed between components or stored in bundles.\u003c/p\u003e\n"]]],["`LocationSettingsStates` stores location-related settings states. Key actions include retrieving states from an intent via `fromIntent()`. It checks for the presence and usability of BLE, GPS, and network location providers using `isBlePresent()`, `isGpsPresent()`, `isNetworkLocationPresent()` and their respective `Usable` counterparts, in addition, it can check if any location provider is available with `isLocationPresent()` and `isLocationUsable()`. It implements `Parcelable` for data transfer, including a `writeToParcel()` method. It has a CREATOR field of type `Parcelable.Creator`.\n"],null,["# LocationSettingsStates\n\npublic final class **LocationSettingsStates** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nimplements [Parcelable](//developer.android.com/reference/android/os/Parcelable.html) \nStores the current states of all location-related settings. \n\n### Inherited Constant Summary\n\nFrom interface android.os.Parcelable \n\n|-----|-------------------------------|---|\n| int | CONTENTS_FILE_DESCRIPTOR | |\n| int | PARCELABLE_WRITE_RETURN_VALUE | |\n\n### Field Summary\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|---|\n| public static final [Creator](//developer.android.com/reference/android/os/Parcelable.Creator.html)\\\u003c[LocationSettingsStates](/android/reference/com/google/android/gms/location/LocationSettingsStates)\\\u003e | [CREATOR](/android/reference/com/google/android/gms/location/LocationSettingsStates#CREATOR) | |\n\n### Public Method Summary\n\n|------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [LocationSettingsStates](/android/reference/com/google/android/gms/location/LocationSettingsStates) | [fromIntent](/android/reference/com/google/android/gms/location/LocationSettingsStates#fromIntent(android.content.Intent))([Intent](//developer.android.com/reference/android/content/Intent.html) intent) Retrieves the location settings states from the intent extras. |\n| boolean | [isBlePresent](/android/reference/com/google/android/gms/location/LocationSettingsStates#isBlePresent())() Whether BLE is present on the device. |\n| boolean | [isBleUsable](/android/reference/com/google/android/gms/location/LocationSettingsStates#isBleUsable())() Whether BLE is enabled and is usable by the app. |\n| boolean | [isGpsPresent](/android/reference/com/google/android/gms/location/LocationSettingsStates#isGpsPresent())() Whether GPS provider is present on the device. |\n| boolean | [isGpsUsable](/android/reference/com/google/android/gms/location/LocationSettingsStates#isGpsUsable())() Whether GPS provider is enabled and is usable by the app. |\n| boolean | [isLocationPresent](/android/reference/com/google/android/gms/location/LocationSettingsStates#isLocationPresent())() Whether location is present on the device. |\n| boolean | [isLocationUsable](/android/reference/com/google/android/gms/location/LocationSettingsStates#isLocationUsable())() Whether location is enabled and is usable by the app. |\n| boolean | [isNetworkLocationPresent](/android/reference/com/google/android/gms/location/LocationSettingsStates#isNetworkLocationPresent())() Whether network location provider is present on the device. |\n| boolean | [isNetworkLocationUsable](/android/reference/com/google/android/gms/location/LocationSettingsStates#isNetworkLocationUsable())() Whether network location provider is enabled and usable by the app. |\n| void | [writeToParcel](/android/reference/com/google/android/gms/location/LocationSettingsStates#writeToParcel(android.os.Parcel,%20int))([Parcel](//developer.android.com/reference/android/os/Parcel.html) dest, int flags) |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFrom interface android.os.Parcelable \n\n|---------------|--------------------------------------------------------------------------------------------------|\n| abstract int | describeContents() |\n| abstract void | writeToParcel([Parcel](//developer.android.com/reference/android/os/Parcel.html) arg0, int arg1) |\n\nFields\n------\n\n#### public static final [Creator](//developer.android.com/reference/android/os/Parcelable.Creator.html)\\\u003c[LocationSettingsStates](/android/reference/com/google/android/gms/location/LocationSettingsStates)\\\u003e\n**CREATOR**\n\nPublic Methods\n--------------\n\n#### public static [LocationSettingsStates](/android/reference/com/google/android/gms/location/LocationSettingsStates)\n**fromIntent** ([Intent](//developer.android.com/reference/android/content/Intent.html) intent)\n\nRetrieves the location settings states from the intent extras. When the location\nsettings dialog finishes, you can use this method to retrieve the current location\nsettings states from the intent in your [Activity.onActivityResult(int, int, Intent)](//developer.android.com/reference/android/app/Activity.html#onActivityResult(int,%20int,%20android.content.Intent)); \n\n#### public boolean **isBlePresent** ()\n\nWhether BLE is present on the device. \n\n#### public boolean **isBleUsable** ()\n\nWhether BLE is enabled and is usable by the app. \n\n#### public boolean **isGpsPresent** ()\n\nWhether GPS provider is present on the device. \n\n#### public boolean **isGpsUsable** ()\n\nWhether GPS provider is enabled and is usable by the app. \n\n#### public boolean **isLocationPresent** ()\n\nWhether location is present on the device.\n\nThis method returns true when either GPS or network location provider is\npresent. \n\n#### public boolean **isLocationUsable** ()\n\nWhether location is enabled and is usable by the app.\n\nThis method returns true when either GPS or network location provider is usable. \n\n#### public boolean **isNetworkLocationPresent** ()\n\nWhether network location provider is present on the device. \n\n#### public boolean **isNetworkLocationUsable** ()\n\nWhether network location provider is enabled and usable by the app. \n\n#### public void **writeToParcel** ([Parcel](//developer.android.com/reference/android/os/Parcel.html) dest, int flags)"]]