Added in API level 35

WifiP2pManager.WifiP2pListener


public static interface WifiP2pManager.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

default void onDeviceConfigurationChanged(WifiP2pDevice p2pDevice)

Called when this device details have changed.

default void onDiscoveryStateChanged(int state)

Called when peer discovery has either started or stopped.

default void onFrequencyChanged(WifiP2pInfo p2pInfo, WifiP2pGroup p2pGroup)

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

default void onGroupCreated(WifiP2pInfo p2pInfo, WifiP2pGroup p2pGroup)

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

default void onGroupCreating()

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

default void onGroupCreationFailed(int reason)

Called when group creation has failed.

default void onGroupNegotiationRejectedByUser()

Called when group negotiation has been rejected by user.

default void onGroupRemoved()

Called when p2p group has been removed.

default void onListenStateChanged(int state)

Called when peer listen has either started or stopped.

default void onP2pStateChanged(int state)

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

default void onPeerClientDisconnected(WifiP2pInfo p2pInfo, WifiP2pGroup p2pGroup)

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

default void onPeerClientJoined(WifiP2pInfo p2pInfo, WifiP2pGroup p2pGroup)

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

default void onPeerListChanged(WifiP2pDeviceList p2pDeviceList)

Called when the available peer list has changed.

Public methods

onDeviceConfigurationChanged

Added in API level 35
public void onDeviceConfigurationChanged (WifiP2pDevice p2pDevice)

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
public void onDiscoveryStateChanged (int state)

Called when peer discovery has either started or stopped.

Parameters
state int: indicates whether discovery has started or stopped. Value is WifiP2pManager.WIFI_P2P_DISCOVERY_STOPPED, or WifiP2pManager.WIFI_P2P_DISCOVERY_STARTED

onFrequencyChanged

Added in API level 35
public void onFrequencyChanged (WifiP2pInfo p2pInfo, 
                WifiP2pGroup p2pGroup)

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
public void onGroupCreated (WifiP2pInfo p2pInfo, 
                WifiP2pGroup p2pGroup)

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
public void onGroupCreating ()

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

onGroupNegotiationRejectedByUser

Added in API level 35
public void onGroupNegotiationRejectedByUser ()

Called when group negotiation has been rejected by user.

onGroupRemoved

Added in API level 35
public void onGroupRemoved ()

Called when p2p group has been removed.

onListenStateChanged

Added in API level 35
public void onListenStateChanged (int state)

Called when peer listen has either started or stopped.

Parameters
state int: indicates whether listen has started or stopped. Value is WifiP2pManager.WIFI_P2P_LISTEN_STOPPED, or WifiP2pManager.WIFI_P2P_LISTEN_STARTED

onP2pStateChanged

Added in API level 35
public void onP2pStateChanged (int state)

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

Parameters
state int: indicates whether Wi-Fi p2p is enabled or disabled. Value is WifiP2pManager.WIFI_P2P_STATE_DISABLED, or WifiP2pManager.WIFI_P2P_STATE_ENABLED

onPeerClientDisconnected

Added in API level 35
public void onPeerClientDisconnected (WifiP2pInfo p2pInfo, 
                WifiP2pGroup p2pGroup)

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
public void onPeerClientJoined (WifiP2pInfo p2pInfo, 
                WifiP2pGroup p2pGroup)

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
public void onPeerListChanged (WifiP2pDeviceList p2pDeviceList)

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.