Stay organized with collections
Save and categorize content based on your preferences.
IdentityChangedListener
open class IdentityChangedListener
Base class for Aware identity/cluster changes callbacks. Should be extended by applications and set when calling WifiAwareManager.attach(AttachCallback, IdentityChangedListener,
. These are callbacks applying to the Aware connection as a whole - not to specific publish or subscribe sessions - for that see DiscoverySessionCallback
.
Summary
Constants |
static Int |
Wi-Fi Aware cluster change event type when joining a cluster.
|
static Int |
Wi-Fi Aware cluster change event type when starting a cluster.
|
Public methods |
open Unit |
Cluster ID changes could be trigger by either cluster started event or cluster joined event.
|
open Unit |
Identity change may be due to device joining a cluster, starting a cluster, or discovery interface change (addresses are randomized at regular intervals).
|
Constants
CLUSTER_CHANGE_EVENT_JOINED
static val CLUSTER_CHANGE_EVENT_JOINED: Int
Wi-Fi Aware cluster change event type when joining a cluster.
Value: 1
CLUSTER_CHANGE_EVENT_STARTED
static val CLUSTER_CHANGE_EVENT_STARTED: Int
Wi-Fi Aware cluster change event type when starting a cluster.
Value: 0
Public constructors
IdentityChangedListener
IdentityChangedListener()
Public methods
onClusterIdChanged
open fun onClusterIdChanged(
clusterEventType: Int,
clusterId: MacAddress
): Unit
Cluster ID changes could be trigger by either cluster started event or cluster joined event.
onIdentityChanged
open fun onIdentityChanged(mac: ByteArray!): Unit
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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# IdentityChangedListener\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nIdentityChangedListener\n=======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/wifi/aware/IdentityChangedListener \"View this page in Java\") \n\n```\nopen class IdentityChangedListener\n```\n\n|---|-----------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.net.wifi.aware.IdentityChangedListener](#) |\n\nBase class for Aware identity/cluster changes callbacks. Should be extended by applications and set when calling [WifiAwareManager.attach(AttachCallback, IdentityChangedListener,](/reference/kotlin/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.net.wifi.aware.IdentityChangedListener,%20android.os.Handler)). These are callbacks applying to the Aware connection as a whole - not to specific publish or subscribe sessions - for that see [DiscoverySessionCallback](/reference/kotlin/android/net/wifi/aware/DiscoverySessionCallback).\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [CLUSTER_CHANGE_EVENT_JOINED](#CLUSTER_CHANGE_EVENT_JOINED:kotlin.Int) Wi-Fi Aware cluster change event type when joining a cluster. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [CLUSTER_CHANGE_EVENT_STARTED](#CLUSTER_CHANGE_EVENT_STARTED:kotlin.Int) Wi-Fi Aware cluster change event type when starting a cluster. |\n\n| Public constructors ||\n|------------------------------------------------------------------|---|\n| [IdentityChangedListener](#IdentityChangedListener())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onClusterIdChanged](#onClusterIdChanged(kotlin.Int,%20android.net.MacAddress))`(`clusterEventType:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `clusterId:` `[MacAddress](../../MacAddress.html#)`)` Cluster ID changes could be trigger by either cluster started event or cluster joined event. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onIdentityChanged](#onIdentityChanged(kotlin.ByteArray))`(`mac:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`)` Identity change may be due to device joining a cluster, starting a cluster, or discovery interface change (addresses are randomized at regular intervals). |\n\nConstants\n---------\n\n### CLUSTER_CHANGE_EVENT_JOINED\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val CLUSTER_CHANGE_EVENT_JOINED: Int\n```\n\nWi-Fi Aware cluster change event type when joining a cluster. \n\n Value: 1\n\n### CLUSTER_CHANGE_EVENT_STARTED\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val CLUSTER_CHANGE_EVENT_STARTED: Int\n```\n\nWi-Fi Aware cluster change event type when starting a cluster. \n\n Value: 0\n\nPublic constructors\n-------------------\n\n### IdentityChangedListener\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nIdentityChangedListener()\n```\n\nPublic methods\n--------------\n\n### onClusterIdChanged\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onClusterIdChanged(\n clusterEventType: Int, \n clusterId: MacAddress\n): Unit\n```\n\nCluster ID changes could be trigger by either cluster started event or cluster joined event.\n\n| Parameters ||\n|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `clusterEventType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The type of events that triggered the change of the cluster ID. Value is [android.net.wifi.aware.IdentityChangedListener#CLUSTER_CHANGE_EVENT_STARTED](#CLUSTER_CHANGE_EVENT_STARTED:kotlin.Int), or [android.net.wifi.aware.IdentityChangedListener#CLUSTER_CHANGE_EVENT_JOINED](#CLUSTER_CHANGE_EVENT_JOINED:kotlin.Int) |\n| `clusterId` | [MacAddress](../../MacAddress.html#): The cluster id that the device just joined. This value cannot be `null`. |\n\n### onIdentityChanged\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onIdentityChanged(mac: ByteArray!): Unit\n```\n\nIdentity 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.\n\n| Parameters ||\n|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mac` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!: The MAC address of the Aware discovery interface. The application must have the [android.Manifest.permission#ACCESS_FINE_LOCATION](../../../Manifest.permission.html#ACCESS_FINE_LOCATION:kotlin.String) to get the actual MAC address, otherwise all 0's will be provided. |"]]