# Class RangingAdapter

java.lang.Object
com.codename1.nearby.ranging.RangingAdapter

All Implemented Interfaces:
  `RangingListener`

public class RangingAdapter extends Object implements 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
  Constructor
  Description
  `RangingAdapter()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `invalidated(NearbyException error)`
  The session died and cannot be restarted.
  `void`
  `peerRemoved(RangingRemovalReason reason)`
  The peer stopped being ranged.
  `void`
  `resumed()`
  A suspended session started running again.
  `void`
  `suspended()`
  The platform paused the session -- typically because the app went to the background without the entitlement that would let it keep ranging.
  `void`
  `updated(RangingUpdate update)`
  A fresh measurement arrived.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### RangingAdapter

    public RangingAdapter()

- ## Method Details

  - ### updated

    public void updated(RangingUpdate update)
    Description copied from interface: `RangingListener`

    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

    - `update`: the measurement
    Specified by:
      `updated` in interface `RangingListener`

  - ### peerRemoved

    public void peerRemoved(RangingRemovalReason reason)
    Description copied from interface: `RangingListener`

    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

    - `reason`: why the peer went away
    Specified by:
      `peerRemoved` in interface `RangingListener`

  - ### suspended

    public void suspended()
    Description copied from interface: `RangingListener`
    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 `RangingListener.resumed()` fires.
    Specified by:
      `suspended` in interface `RangingListener`

  - ### resumed

    public void resumed()
    Description copied from interface: `RangingListener`
    A suspended session started running again.
    Specified by:
      `resumed` in interface `RangingListener`

  - ### invalidated

    public void invalidated(NearbyException error)
    Description copied from interface: `RangingListener`

    The 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:
      `invalidated` in interface `RangingListener`