public class FusedLocationHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
lastLocationReqStarted |
static boolean |
locationButtonClicked |
static boolean |
locationUpdatesEnabled |
static int |
REQUEST_CODE_LAST_LOCATION |
static int |
REQUEST_CODE_LOCATION_UPDATES |
Constructor and Description |
---|
FusedLocationHelper(android.content.Context context,
TPLLocationListener listener)
Constructor to new initialize and instance of
FusedLocationHelper class |
Modifier and Type | Method and Description |
---|---|
Config |
config()
Get
Config to modify/set location configurations |
void |
enableLocationUpdates(boolean enable)
Set Location Updates on/off (true/false) for continuous updates.
|
TPLLocationListener |
getListener() |
boolean |
getLocationUpdatesEnabled() |
MapController.MyLocationArg |
getMyLocationArg() |
void |
initiateLastLocationRequest() |
boolean |
isFirstFix() |
void |
locationLogic(boolean isLastLocation,
android.location.Location location)
Function make sure the
TPLLocationListener 's callbacks |
void |
onActivityResult(int requestCode,
int resultCode,
android.content.Intent data) |
void |
onDestroy() |
void |
onPause() |
void |
onRequestPermissionsResult(int requestCode,
java.lang.String[] permissions,
int[] grantResults)
Callback for the result from requesting permissions.
|
void |
onResume() |
void |
onStart() |
void |
onStop() |
void |
resetLocationSettingsDialogPrefs()
Resets Location Settings Dialog preference to re-appear Dialog
|
void |
setFirstFix(boolean value) |
void |
setMyLocationArg(MapController.MyLocationArg arg) |
void |
startGettingLocation(boolean isLastLocationRequest)
Check if the device's location settings are adequate for the app's needs using the
LocationServices.getSettingsClient(Activity) method,
with the results provided by LocationSettingsResponse and started tracking location
OR fetch last location based on isRequestForLastLocation flag, when resolved. |
void |
stopLocationUpdates()
Stop location updates
|
public static final int REQUEST_CODE_LAST_LOCATION
public static final int REQUEST_CODE_LOCATION_UPDATES
public static boolean lastLocationReqStarted
public static boolean locationButtonClicked
public static boolean locationUpdatesEnabled
public FusedLocationHelper(android.content.Context context, TPLLocationListener listener)
FusedLocationHelper
classcontext
- Context
of referenced classlistener
- an instance of interface
TPLLocationListener
public void setMyLocationArg(MapController.MyLocationArg arg)
public MapController.MyLocationArg getMyLocationArg()
public void onRequestPermissionsResult(int requestCode, @NonNull java.lang.String[] permissions, @NonNull int[] grantResults)
androidx.fragment.app.FragmentActivity#requestPermissions(String[], int)
.
Note: It is possible that the permissions request interaction with the user is interrupted. In this case you will receive empty permissions and results arrays which should be treated as a cancellation.
For more description: ActivityCompat.OnRequestPermissionsResultCallback.onRequestPermissionsResult(int, String[], int[])
}
androidx.fragment.app.FragmentActivity#requestPermissions(String[], int)
public TPLLocationListener getListener()
public void locationLogic(boolean isLastLocation, android.location.Location location)
TPLLocationListener
's callbacksisLastLocation
- pass true if the provided location is for
TPLLocationListener.onLastLocationRequest(Location)
method, otherwise false
for location updates callback methodslocation
- Location
objectpublic void onStart()
public void onResume()
public void onStop()
public void onPause()
public void setFirstFix(boolean value)
public boolean isFirstFix()
public void onDestroy()
public void startGettingLocation(boolean isLastLocationRequest)
LocationServices.getSettingsClient(Activity)
method,
with the results provided by LocationSettingsResponse
and started tracking location
OR fetch last location based on isRequestForLastLocation flag, when resolved.isLastLocationRequest
- Pass true to get last location and false to get location updatespublic void resetLocationSettingsDialogPrefs()
public void enableLocationUpdates(boolean enable)
NOTE: Method will work only with
MapController.setMyLocationEnabled(boolean)
's call.
enable
- boolean
true/falsepublic boolean getLocationUpdatesEnabled()
public void initiateLastLocationRequest()
public void stopLocationUpdates()
public void onActivityResult(int requestCode, int resultCode, android.content.Intent data)