public abstract static class Position.Handle extends Object
OnLocation
annotation. Such annotation will generate a subclass for you automatically
with two static methods createQuery
and createWatch
which can be used to obtain instance of this class.Modifier | Constructor and Description |
---|---|
protected |
Handle(boolean oneTime)
Creates new instance of this handle.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isSupported()
Check whether the location API is supported.
|
protected abstract void |
onError(Exception ex)
Callback when an error occurs.
|
protected abstract void |
onLocation(Position p)
Callback from the implementation when a (new) position has been
received and identified
|
void |
setHighAccuracy(boolean enable)
Turns on high accuracy mode as specified by the
W3C's Geolocation API.
|
void |
setMaximumAge(long age)
Sets maximum age of cached results which are acceptable to be
returned.
|
void |
setTimeout(long timeout)
The amount of milliseconds to wait for a result.
|
void |
start()
Initializes the query or watch request(s) and
returns immediately.
|
void |
stop()
Stops all pending requests.
|
protected Handle(boolean oneTime)
oneTime
- true
if the handle represents one time
query. false
if it represents a watchprotected abstract void onLocation(Position p) throws Throwable
p
- the positionThrowable
- if an exception is thrown, it will be logged by the systemprotected abstract void onError(Exception ex) throws Throwable
ex
- the exception describing what went wrongThrowable
- if an exception is thrown, it will be logged by the systempublic final boolean isSupported()
Position.Handle.start()
.public final void setHighAccuracy(boolean enable)
enable
- true
or false
public final void setTimeout(long timeout)
timeout
- time in milliseconds to wait for a result.public final void setMaximumAge(long age)
age
- time in milliseconds of acceptable cached resultspublic final void start()
Position.Handle.onError(java.lang.Exception)
callback. For example, if the Position.Handle.isSupported()
method
returns false
an IllegalStateException is created
and sent to the callback
method.public final void stop()
Copyright © 2021 The Apache Software Foundation. All rights reserved.