public class LocationHandlerThread extends HandlerThread
It doesn't internally deal with the LOCATION permissions, so once instantiated, a Thread.UncaughtExceptionHandler should be added to it in order to catch the potential SecurityExceptions.
The thread is started with Thread.start(), but the location updates will only start after having called resumeLocationUpdates().
The location updates can be stopped with pauseLocationUpdates() and the HandlerThread itself should be stopped with HandlerThread.quit() or HandlerThread.quitSafely().
Thread.State, Thread.UncaughtExceptionHandlerMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
LocationHandlerThread(Context context,
String name,
int priority)
Constructs a new LocationHandlerThread.
|
| Modifier and Type | Method and Description |
|---|---|
Location |
getLocation()
Returns the latest Location that was obtained from the system.
|
protected void |
onLooperPrepared() |
void |
pauseLocationUpdates()
Pauses the location updates from the system location services.
|
void |
resumeLocationUpdates()
Resumes the location updates from the system location services.
|
getLooper, getThreadId, quit, quitSafely, runactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprotected void onLooperPrepared()
onLooperPrepared in class HandlerThreadpublic Location getLocation()
public void resumeLocationUpdates()
public void pauseLocationUpdates()