IdentityChangedListener


public class IdentityChangedListener
extends Object

java.lang.Object
   ↳ android.net.wifi.aware.IdentityChangedListener


Base class for Aware identity/cluster changes callbacks. Should be extended by applications and set when calling WifiAwareManager#attach(AttachCallback, IdentityChangedListener, android.os.Handler). These are callbacks applying to the Aware connection as a whole - not to specific publish or subscribe sessions - for that see DiscoverySessionCallback.

Summary

Constants

int CLUSTER_CHANGE_EVENT_JOINED

Wi-Fi Aware cluster change event type when joining a cluster.

int CLUSTER_CHANGE_EVENT_STARTED

Wi-Fi Aware cluster change event type when starting a cluster.

Public constructors

IdentityChangedListener()

Public methods

void onClusterIdChanged(int clusterEventType, MacAddress clusterId)

Cluster ID changes could be trigger by either cluster started event or cluster joined event.

void onIdentityChanged(byte[] mac)

Identity change may be due to device joining a cluster, starting a cluster, or discovery interface change (addresses are randomized at regular intervals).

Inherited methods

Constants

CLUSTER_CHANGE_EVENT_JOINED

Added in API level 34
public static final int CLUSTER_CHANGE_EVENT_JOINED

Wi-Fi Aware cluster change event type when joining a cluster.

Constant Value: 1 (0x00000001)

CLUSTER_CHANGE_EVENT_STARTED

Added in API level 34
public static final int CLUSTER_CHANGE_EVENT_STARTED

Wi-Fi Aware cluster change event type when starting a cluster.

Constant Value: 0 (0x00000000)

Public constructors

IdentityChangedListener

Added in API level 26
public IdentityChangedListener ()

Public methods

onClusterIdChanged

Added in API level 34
public void onClusterIdChanged (int clusterEventType, 
                MacAddress clusterId)

Cluster ID changes could be trigger by either cluster started event or cluster joined event.

Parameters
clusterEventType int: The type of events that triggered the change of the cluster ID. Value is CLUSTER_CHANGE_EVENT_STARTED, or CLUSTER_CHANGE_EVENT_JOINED

clusterId MacAddress: The cluster id that the device just joined. This value cannot be null.

onIdentityChanged

Added in API level 26
public void onIdentityChanged (byte[] mac)

Identity change may be due to device joining a cluster, starting a cluster, or discovery interface change (addresses are randomized at regular intervals). The implication is that peers you've been communicating with may no longer recognize you and you need to re-establish your identity - e.g. by starting a discovery session.

Parameters
mac byte: The MAC address of the Aware discovery interface. The application must have the Manifest.permission.ACCESS_FINE_LOCATION to get the actual MAC address, otherwise all 0's will be provided.