Class LocationTrackingHelper
- java.lang.Object
-
- com.cheetahdigital.corekit.helpers.LocationTrackingHelper
-
public class LocationTrackingHelper extends java.lang.Object
Helper class for accessing and modifying location related data
-
-
Constructor Summary
Constructors Constructor Description LocationTrackingHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getLocation(android.content.Context context)
Returns the most recent location.static boolean
isAppLocationPermissionEnabled(android.content.Context context)
Returns the status of location permission in the app device settingsstatic boolean
isLocationServiceEnabled(android.content.Context context)
Returns the status of location services in the OS levelstatic boolean
isUserPermissionEnabled(android.content.Context context)
Returns the status of user permission in the app levelstatic void
saveLocation(android.content.Context context, android.location.Location location)
Stores the location in preferences The latitude and longitude are saved in the preferences in the following format: { “lat”: 40.759211, “lon”: -73.984638} If the location is null or empty, an empty string will be stored in the preferencesstatic void
setUserPermission(android.content.Context context, boolean isEnabled)
Sets the status of user permission in the app level
-
-
-
Method Detail
-
getLocation
public static java.lang.String getLocation(android.content.Context context)
Returns the most recent location. If the location services and app location permission are disabled, an empty string will be returned- Parameters:
context
- The context to use for getting location- Returns:
- String which contains the latitude and longitude in the following format: { “lat”: 40.759211, “lon”: -73.984638}
-
saveLocation
public static void saveLocation(android.content.Context context, android.location.Location location)
Stores the location in preferences The latitude and longitude are saved in the preferences in the following format: { “lat”: 40.759211, “lon”: -73.984638} If the location is null or empty, an empty string will be stored in the preferences- Parameters:
context
- The context to use to store the locationlocation
- data to be stored
-
isUserPermissionEnabled
public static boolean isUserPermissionEnabled(android.content.Context context)
Returns the status of user permission in the app level- Parameters:
context
- used to get resources- Returns:
- true - user allows tracking of location, false - user does not allow tracking of location
-
setUserPermission
public static void setUserPermission(android.content.Context context, boolean isEnabled)
Sets the status of user permission in the app level- Parameters:
context
- used to get resourcesisEnabled
- true - user allows tracking of location, false - user does not allow tracking of location
-
isAppLocationPermissionEnabled
public static boolean isAppLocationPermissionEnabled(android.content.Context context)
Returns the status of location permission in the app device settings- Parameters:
context
- used to get resources- Returns:
- true - the application is allowed to retrieve user's current location, false - the application does not allow the user to retrieve the user's current location
-
isLocationServiceEnabled
public static boolean isLocationServiceEnabled(android.content.Context context)
Returns the status of location services in the OS level- Parameters:
context
- used to get resources- Returns:
- true - allows retrieving of location, false - does not allow retrieving location
-
-