FusedLocationProvider
Comment:
- The FusedLocationProvider intelligently manages the underlying location technology and gives you the best location according to your needs.
https://developer.android.com/google/play-services/location.html
This library depends on the Google Play Services library, android-support-v4 library and the GPS library.
The GPS library is required in order to use it's Location object.
ConnectionResult
Fields:
- API_UNAVAILABLE As Int
One of the API components you attempted to connect to is not available.
- CANCELLED As Int
The client cancelled the connection by calling Disconnect().
- DEVELOPER_ERROR As Int
The application is misconfigured.
- INTERNAL_ERROR As Int
An internal error occurred.
- INVALID_ACCOUNT As Int
The client attempted to connect to the service with an invalid account name specified.
- LICENSE_CHECK_FAILED As Int
The application is not licensed to the user. This error is not recoverable and will be treated as fatal.
- NETWORK_ERROR As Int
A network error occurred. Retrying should resolve the problem.
- RESOLUTION_REQUIRED As Int
Completing the connection requires some form of resolution.
- SERVICE_DISABLED As Int
The installed version of Google Play services has been disabled on this device.
- SERVICE_INVALID As Int
The version of the Google Play services installed on this device is not authentic.
- SERVICE_MISSING As Int
Google Play services is missing on this device.
- SERVICE_VERSION_UPDATE_REQUIRED As Int
The installed version of Google Play services is out of date.
- SIGN_IN_REQUIRED As Int
The client attempted to connect to the service but the user is not signed in.
- SUCCESS As Int
The connection was successful.
FusedLocationProvider
Events:
- ConnectionFailed (ConnectionResult1 As Int)
- ConnectionSuccess
- ConnectionSuspended (SuspendedCause1 As Int)
- LocationChanged (Location1 As Location)
- LocationSettingsChecked (LocationSettingsResult1 As LocationSettingsResult)
Fields:
- ConnectionResult As ConnectionResult
Contains the various ConnectionResult constants.
- SuspendedCause As SuspendedCause
Contains the various SuspendedCause constants.
Methods:
- CheckLocationSettings (LocationSettingsRequest1 As LocationSettingsRequest)
Checks if the relevant system settings are enabled on the device to carry out the desired location requests.
Raises the event:
LocationSettingsChecked(LocationSettingsResult1 As LocationSettingsResult)
- Connect
Attempt to connect to the Location Services.
Will raise either event:
ConnectionFailed(ConnectionResult1 As Int)
ConnectionSuccess
- Disconnect
Disconnect from the Location Services.
- GetLastKnownLocation As LocationWrapper
Returns the best most recent location currently available.
Can only be called if the FusedLocationProvider is connected.
The returned Location object will not be initialized if no last known location is available.
- Initialize (EventName As String)
Initialize the FusedLocationProvider object.
- IsConnected As Boolean
Returns whether the FusedLocationProvider is connected to the Location Services.
- IsConnecting As Boolean
Returns whether the FusedLocationProvider is trying to connect to the Location Services.
- IsInitialized As Boolean
- RemoveLocationUpdates
Remove all requests for location updates.
- RequestLocationUpdates (LocationRequest1 As LocationRequest)
Request for location updates.
The LocationRequest object defines the criteria for which location updates are requested.
LocationRequest
Fields:
- Priority As Priority
Contains the various priority constants.
Methods:
- GetExpirationTime As Long
Get the request expiration time, in milliseconds since boot.
- GetFastestInterval As Long
Get the fastest interval of this request, in milliseconds.
- GetInterval As Long
Get the desired interval of this request, in milliseconds.
- GetNumUpdates As Int
Get the number of updates requested.
- GetPriority As Int
Get the quality of the request.
- GetSmallestDisplacement As Float
Get the minimum displacement between location updates in meters.
By default this is 0.
- Initialize
Initialize the LocationRequest with default parameters.
Default parameters are for a block accuracy, slowly updated location.
- IsInitialized As Boolean
- SetExpirationDuration (Millis As Long) As LocationRequest
Set the duration of this request, in milliseconds.
- SetExpirationTime (Millis As Long) As LocationRequest
Set the request expiration time, in millisecond since boot.
- SetFastestInterval (Millis As Long) As LocationRequest
Explicitly set the fastest interval for location updates, in milliseconds.
- SetInterval (Millis As Long) As LocationRequest
Set the desired interval for active location updates, in milliseconds.
- SetNumUpdates (NumUpdates As Int) As LocationRequest
Set the number of location updates.
- SetPriority (Priority As Int) As LocationRequest
Set the priority of the request.
- SetSmallestDisplacement (SmallestDisplacementMeters As Float) As LocationRequest
Set the minimum displacement between location updates in meters.
By default this is 0.
LocationSettingsRequestBuilder
Methods:
- AddLocationRequest (LocationRequest1 As LocationRequest) As LocationSettingsRequestBuilder
Adds one LocationRequest that the client is interested in.
This method can be called multiple times if required to add additional location requests.
- Build As LocationSettingsRequest
Creates a LocationSettingsRequest.
- Initialize
- IsInitialized As Boolean
- SetAlwaysShow (AlwaysShow As Boolean) As LocationSettingsRequestBuilder
Always show the dialog, without the "Never" option to suppress future dialogs from this app.
When this flag is set to true, the dialog will show up if the location settings do not satisfy the request, even if a user has previously chosen "Never".
NOTE: Only use this method if your dialog is the result of an explicit user-initiated action that requires location to proceed.
Cancelling this dialog should also cancel the initiated action.
- SetNeedBle (NeedBle As Boolean) As LocationSettingsRequestBuilder
Sets whether the client wants BLE scan to be enabled.
When this flag is set to true, if the platform supports BLE scan mode and Bluetooth is off, the dialog will prompt the user to enable BLE scan.
If the platform doesn't support BLE scan mode, the dialog will prompt to enable Bluetooth.
LocationSettingsResult
Methods:
- GetLocationSettingsStates As LocationSettingsStates
Returns the location settings states.
- GetLocationSettingsStatus As LocationSettingsStatus
Returns the location settings result status.
- IsInitialized As Boolean
LocationSettingsStates
Methods:
- IsBlePresent As Boolean
Whether BLE is present on the device.
- IsBleusable As Boolean
Whether BLE is enabled and is usable by the app.
- IsGpsPresent As Boolean
Whether GPS provider is present on the device.
- IsGpsUsable As Boolean
Whether GPS provider is enabled and is usable by the app.
- IsInitialized As Boolean
- IsLocationPresent As Boolean
Whether location is present on the device.
This method returns true when either GPS or network location provider is present.
- IsLocationUsable As Boolean
Whether location is enabled and is usable by the app.
This method returns true when either GPS or network location provider is usable.
- IsNetworkLocationPresent As Boolean
Whether network location provider is present on the device.
- IsNetworkLocationUsable As Boolean
Whether network location provider is enabled and usable by the app.
LocationSettingsStatus
Events:
- ResolutionDialogDismissed (LocationSettingsUpdated As Boolean)
Fields:
- StatusCodes As StatusCodes
Contains the various StatusCode constants.
Methods:
- GetStatusCode As Int
Returns the status code that describes whether the location settings meet the location request requirements.
- IsInitialized As Boolean
- StartResolutionDialog (EventName As String)
Starts the resolution dialog.
The user can then enable the location settings required to meet the location request requirements.
This method must be called from an Activity.
Raises the event:
ResolutionDialogDismissed(LocationSettingsUpdated As Boolean)
Priority
Fields:
- PRIORITY_BALANCED_POWER_ACCURACY As Int
Used with SetPriority(Int) to request "block" level accuracy.
- PRIORITY_HIGH_ACCURACY As Int
Used with SetPriority(Int) to request the most accurate locations available.
- PRIORITY_LOW_POWER As Int
Used with SetPriority(Int) to request "city" level accuracy.
- PRIORITY_NO_POWER As Int
Used with SetPriority(Int) to request the best accuracy possible with zero additional power consumption.
StatusCodes
Fields:
- RESOLUTION_REQUIRED As Int
Location settings do not meet the location request requirements.
Location settings can be changed to meet the location request requirements.
A resolution dialog is available.
- SETTINGS_CHANGE_UNAVAILABLE As Int
Location settings do not meet the location request requirements.
Location settings can't be changed to meet the location request requirements.
No resolution dialog is available.
- SUCCESS As Int
Location settings meet the location request requirements.
SuspendedCause
Fields:
- CAUSE_NETWORK_LOST As Int
A connection suspended cause informing you that a peer device connection was lost.
- CAUSE_SERVICE_DISCONNECTED As Int
A connection suspended cause informing that the service has been killed.