Added in API level 35

WifiP2pListener


interface WifiP2pListener
android.net.wifi.p2p.WifiP2pManager.WifiP2pListener

Interface used to listen to Wi-Fi p2p various changes such as device state change, discovery started/stopped, connection change, etc.

Summary

Public methods
open Unit

Called when this device details have changed.

open Unit

Called when peer discovery has either started or stopped.

open Unit

Called when the frequency of a formed group has been changed.

open Unit
onGroupCreated(p2pInfo: WifiP2pInfo, p2pGroup: WifiP2pGroup)

Called when either group owner or group client has created p2p group successfully.

open Unit

Called when either group owner or group client is creating p2p group.

open Unit

Called when group creation has failed.

open Unit

Called when group negotiation has been rejected by user.

open Unit

Called when p2p group has been removed.

open Unit

Called when peer listen has either started or stopped.

open Unit

Called when Wi-Fi p2p has been enabled or disabled.

open Unit

Called to indicate group owner that a group client has disconnected.

open Unit

Called to indicate group owner that a group client has joined p2p group successfully.

open Unit

Called when the available peer list has changed.

Public methods

onDeviceConfigurationChanged

Added in API level 35
open fun onDeviceConfigurationChanged(p2pDevice: WifiP2pDevice?): Unit

Called when this device details have changed.

Parameters
p2pDevice WifiP2pDevice?: provides this device details. This value may be null.

onDiscoveryStateChanged

Added in API level 35
open fun onDiscoveryStateChanged(state: Int): Unit

Called when peer discovery has either started or stopped.

Parameters
state Int: indicates whether discovery has started or stopped. Value is android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_DISCOVERY_STOPPED, or android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_DISCOVERY_STARTED

onFrequencyChanged

Added in API level 35
open fun onFrequencyChanged(
    p2pInfo: WifiP2pInfo,
    p2pGroup: WifiP2pGroup
): Unit

Called when the frequency of a formed group has been changed.

Parameters
p2pInfo WifiP2pInfo: provides the p2p connection info. This value cannot be null.
p2pGroup WifiP2pGroup: provides the details of the group. This value cannot be null.

onGroupCreated

Added in API level 35
open fun onGroupCreated(
    p2pInfo: WifiP2pInfo,
    p2pGroup: WifiP2pGroup
): Unit

Called when either group owner or group client has created p2p group successfully.

Parameters
p2pInfo WifiP2pInfo: provides the p2p connection info. This value cannot be null.
p2pGroup WifiP2pGroup: provides the details of the group. This value cannot be null.

onGroupCreating

Added in API level 35
open fun onGroupCreating(): Unit

Called when either group owner or group client is creating p2p group.

onGroupNegotiationRejectedByUser

Added in API level 35
open fun onGroupNegotiationRejectedByUser(): Unit

Called when group negotiation has been rejected by user.

onGroupRemoved

Added in API level 35
open fun onGroupRemoved(): Unit

Called when p2p group has been removed.

onListenStateChanged

Added in API level 35
open fun onListenStateChanged(state: Int): Unit

Called when peer listen has either started or stopped.

Parameters
state Int: indicates whether listen has started or stopped. Value is android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_LISTEN_STOPPED, or android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_LISTEN_STARTED

onP2pStateChanged

Added in API level 35
open fun onP2pStateChanged(state: Int): Unit

Called when Wi-Fi p2p has been enabled or disabled.

Parameters
state Int: indicates whether Wi-Fi p2p is enabled or disabled. Value is android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_DISABLED, or android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_ENABLED

onPeerClientDisconnected

Added in API level 35
open fun onPeerClientDisconnected(
    p2pInfo: WifiP2pInfo,
    p2pGroup: WifiP2pGroup
): Unit

Called to indicate group owner that a group client has disconnected.

Parameters
p2pInfo WifiP2pInfo: provides the p2p connection info. This value cannot be null.
p2pGroup WifiP2pGroup: provides the details of the group. This value cannot be null.

onPeerClientJoined

Added in API level 35
open fun onPeerClientJoined(
    p2pInfo: WifiP2pInfo,
    p2pGroup: WifiP2pGroup
): Unit

Called to indicate group owner that a group client has joined p2p group successfully.

Parameters
p2pInfo WifiP2pInfo: provides the p2p connection info. This value cannot be null.
p2pGroup WifiP2pGroup: provides the details of the group. This value cannot be null.

onPeerListChanged

Added in API level 35
open fun onPeerListChanged(p2pDeviceList: WifiP2pDeviceList): Unit

Called when the available peer list has changed. This can be sent as a result of peers being found, lost or updated.

Parameters
p2pDeviceList WifiP2pDeviceList: provides the full list of current peers. This value cannot be null.