public abstract class LocationEngine
extends java.lang.Object
LostLocationEngine found inside the libandroid-services
module.| Modifier and Type | Class and Description |
|---|---|
static class |
LocationEngine.Type |
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Integer |
fastestInterval |
protected java.lang.Integer |
interval |
protected java.util.concurrent.CopyOnWriteArrayList<LocationEngineListener> |
locationListeners |
protected int |
priority |
protected java.lang.Float |
smallestDisplacement |
| Constructor and Description |
|---|
LocationEngine()
Construct a location engine.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
activate()
Activate the location engine which will connect whichever location provider you are using.
|
void |
addLocationEngineListener(LocationEngineListener listener)
Useful when you'd like to add a location listener to handle location connections and update events.
|
abstract void |
deactivate()
Disconnect the location engine, useful when you no longer need location updates or requesting the users
getLastLocation(). |
int |
getFastestInterval()
Get the current fastest interval being used to receive location updates.
|
int |
getInterval()
Get the current interval being used to receive location updates.
|
abstract android.location.Location |
getLastLocation()
When first initializing the location engine the location updates oftentimes aren't immediate and your user
experience might diminish since they are forced to wait till a more accurate update arrives.
|
int |
getPriority()
Get the current priority being used.
|
float |
getSmallestDisplacement()
Get the current smallest displacement being used to receive location updates.
|
protected static boolean |
isBetterLocation(android.location.Location location,
android.location.Location currentBestLocation)
Determines whether one Location reading is better than the current Location fix.
|
abstract boolean |
isConnected()
Check if your location provider has been activated/connected.
|
abstract LocationEngine.Type |
obtainType()
Get the current
LocationEngine LocationEngine.Type being used. |
boolean |
removeLocationEngineListener(LocationEngineListener listener)
If you no longer need your
LocationEngineListener to be invoked with every location update, use this
method to remove it. |
abstract void |
removeLocationUpdates()
When you no longer wish to receive location updates, you should call this method to prevent the devices battery
from draining.
|
abstract void |
requestLocationUpdates()
if a
LocationEngineListener is setup, registering for location updates will tell the provider to begin
sending updates. |
void |
setFastestInterval(int fastestInterval)
Set the fastest rate in milliseconds at which your application can handle location updates.
|
void |
setInterval(int interval)
Set the rate in milliseconds at which your app prefers to receive location updates.
|
void |
setPriority(int priority)
This method sets the priority of the request, providing this will help the location provide know which location
sources to use.
|
void |
setSmallestDisplacement(float smallestDisplacement)
Set the smallest distance value in meters at which the user must move before a new location update comes in.
|
protected int priority
protected java.lang.Integer interval
protected java.lang.Integer fastestInterval
protected java.lang.Float smallestDisplacement
protected java.util.concurrent.CopyOnWriteArrayList<LocationEngineListener> locationListeners
public abstract void activate()
requestLocationUpdates().public abstract void deactivate()
getLastLocation(). Before deactivating you'll need to stop request user location updates
using removeLocationUpdates().public abstract boolean isConnected()
public abstract android.location.Location getLastLocation()
Location
object is simply stored in cache.Location object.public abstract void requestLocationUpdates()
LocationEngineListener is setup, registering for location updates will tell the provider to begin
sending updates.public abstract void removeLocationUpdates()
removeLocationEngineListener(LocationEngineListener).public abstract LocationEngine.Type obtainType()
LocationEngine LocationEngine.Type being used.LocationEngine.Type enum.public int getPriority()
LocationEnginePriority file.public void setPriority(int priority)
LocationEnginePriority file.priority - One of the LocationEnginePrioritys listed.public int getInterval()
public void setInterval(int interval)
interval - integer in milliseconds defining the rate in which you'd like to receive location updates.public int getFastestInterval()
public void setFastestInterval(int fastestInterval)
fastestInterval - in milliseconds at which your app can handle location updates.public float getSmallestDisplacement()
public void setSmallestDisplacement(float smallestDisplacement)
smallestDisplacement - in meters which the user must move before a new location update's supplied.public void addLocationEngineListener(LocationEngineListener listener)
removeLocationEngineListener(LocationEngineListener)
inside your activities onStop() method.listener - A LocationEngineListener which you'd like to add to your location engine.public boolean removeLocationEngineListener(LocationEngineListener listener)
LocationEngineListener to be invoked with every location update, use this
method to remove it. It's also important to remove your listeners before the activity is destroyed to prevent any
potential memory leaks.listener - the LocationEngineListener you'd like to remove from this LocationEngine.protected static boolean isBetterLocation(android.location.Location location,
android.location.Location currentBestLocation)
location - The new Location that you want to evaluate.currentBestLocation - The current Location fix, to which you want to compare the new one.