public class RangingAdapter
- Object
- RangingAdapter
ImplementsRangingListener
A RangingListener whose methods all do nothing, so a caller interested
in one event overrides one method.
session.addRangingListener(new RangingAdapter() {
public void updated(RangingUpdate u) {
if (u.hasDistance()) {
label.setText(Math.round(u.getDistance(RangingUnit.CENTIMETERS)) + " cm");
}
}
});
Constructors
public RangingAdapter() |
Methods
public void updated(RangingUpdate update) | A fresh measurement arrived. |
public void peerRemoved(RangingRemovalReason reason) | The peer stopped being ranged. |
public void suspended() | The platform paused the session – typically because the app went to the background without the entitlement that would let it keep ranging. |
public void resumed() | A suspended session started running again. |
public void invalidated(NearbyException error) | The session died and cannot be restarted. |
Inherited methods
Constructor details
RangingAdapter
public RangingAdapter()Method details
updated
public void updated(RangingUpdate update)A fresh measurement arrived. Expect these several times a second
while the peer is in range, and expect individual fields to drop in
and out – see
RangingUpdate.Parameters
updateRangingUpdate- the measurement
peerRemoved
public void peerRemoved(RangingRemovalReason reason)The peer stopped being ranged. The session stays alive and will
resume delivering updates if the peer comes back, so this is a cue
to gray the UI out rather than to tear it down.
Parameters
reasonRangingRemovalReason- why the peer went away
suspended
public void suspended()The platform paused the session – typically because the app went to
the background without the entitlement that would let it keep
ranging. No updates arrive until
resumed fires.resumed
public void resumed()A suspended session started running again.
invalidated
public void invalidated(NearbyException error)The session died and cannot be restarted. Any further call on it
fails; prepare a new session if the feature is still wanted.
Parameters
errorNearbyException- why the session ended