Android Broadcaster Listener

The listener of the Broadcaster is used to observe the device's state changes and for discovered/lost Links.

State Change

CALLBACK FOR WHEN THE BROADCASTER'S STATE HAS CHANGED.

Declaration

void onStateChanged(Broadcaster.State oldState);

Parameters

oldState

The old state of the Broadcaster.

Example

    @Override
    public void onStateChanged(State state) {
        switch (broadcaster.getState()) {
            case BROADCASTING:
                // Device now started broadcasting
                break;
            ...
            }
        }
    }

Proximity events

CALLBACK FOR WHEN A NEW LINK HAS CONNECTED TO THE BROADCASTER.

Declaration

void onLinkReceived(ConnectedLink link);

Parameters

link

The link that successfully connected to the Broadcaster.

Read More

Example

@Override
public void onLinkReceived(ConnectedLink connectedLink) {
    link.setListener(this);
    // connected link has been received
}

CALLBACK FOR WHEN A LINK HAS DISCONNECTED FROM THE BROADCASTER.

Declaration

void onLinkLost(ConnectedLink link);

Parameters

link

The link that disconnected from the Broadcaster.

Read More

Example

@Override
public void onLinkLost(ConnectedLink connectedLink) {
    connectedLink.setListener(null);
    // link has been lost
}