Class RangingAdapter
java.lang.Object
com.codename1.nearby.ranging.RangingAdapter
- All Implemented Interfaces:
RangingListener
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");
}
}
});
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinvalidated(NearbyException error) The session died and cannot be restarted.voidpeerRemoved(RangingRemovalReason reason) The peer stopped being ranged.voidresumed()A suspended session started running again.voidThe platform paused the session -- typically because the app went to the background without the entitlement that would let it keep ranging.voidupdated(RangingUpdate update) A fresh measurement arrived.
-
Constructor Details
-
RangingAdapter
public RangingAdapter()
-
-
Method Details
-
updated
Description copied from interface:RangingListenerA 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
update: the measurement
- Specified by:
updatedin interfaceRangingListener
-
peerRemoved
Description copied from interface:RangingListenerThe 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
reason: why the peer went away
- Specified by:
peerRemovedin interfaceRangingListener
-
suspended
public void suspended()Description copied from interface:RangingListenerThe platform paused the session -- typically because the app went to the background without the entitlement that would let it keep ranging. No updates arrive untilRangingListener.resumed()fires.- Specified by:
suspendedin interfaceRangingListener
-
resumed
public void resumed()Description copied from interface:RangingListenerA suspended session started running again.- Specified by:
resumedin interfaceRangingListener
-
invalidated
Description copied from interface:RangingListenerThe session died and cannot be restarted. Any further call on it fails; prepare a new session if the feature is still wanted.
Parameters
error: why the session ended
- Specified by:
invalidatedin interfaceRangingListener
-