Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#constants) \| [Inherited Constants](https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#inhconstants) \| [Fields](https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#lfields) \| [Ctors](https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#pubctors) \| [Methods](https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#inhmethods)

# WifiP2pGroup

*** ** * ** ***


`
public


class
WifiP2pGroup
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.wifi.p2p.WifiP2pGroup |

<br />

*** ** * ** ***

A class representing a Wi-Fi P2p group. A p2p group consists of a single group
owner and one or more clients. In the case of a group with only two devices, one
will be the group owner and the other will be a group client.
**See also:**

- `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager`

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#NETWORK_ID_PERSISTENT` The persistent network id. |
| `int` | `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#NETWORK_ID_TEMPORARY` The temporary network id. |
| `int` | `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#SECURITY_TYPE_UNKNOWN` The definition of security type unknown. |
| `int` | `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#SECURITY_TYPE_WPA2_PSK` The definition of security type WPA2-PSK. |
| `int` | `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#SECURITY_TYPE_WPA3_COMPATIBILITY` The definition of security type WPA3-Compatibility Mode. |
| `int` | `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#SECURITY_TYPE_WPA3_SAE` The definition of security type WPA3-SAE. |

| ### Inherited constants |
|---|
| From interface `https://developer.android.com/reference/android/os/Parcelable` |---|---| | `int` | `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. | | `int` | `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup>` | `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#CREATOR` Implement the Parcelable interface |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#WifiP2pGroup()() ` |
| ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#WifiP2pGroup(android.net.wifi.p2p.WifiP2pGroup)(https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup source) ` copy constructor |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#describeContents()() ` Implement the Parcelable interface |
| ` https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pDevice>` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getClientList()() ` Get the list of clients currently part of the p2p group |
| ` int` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getFrequency()() ` Get the operating frequency (in MHz) of the p2p group |
| ` https://developer.android.com/reference/android/net/MacAddress` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getGroupOwnerBssid()() ` Returns the BSSID, if this device is the group owner of the P2P group supporting Wi-Fi Direct R2 protocol. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getInterface()() ` Get the interface name on which the group is created |
| ` int` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getNetworkId()() ` The network ID of the P2P group in wpa_supplicant. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getNetworkName()() ` Get the network name (SSID) of the group. |
| ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pDevice` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getOwner()() ` Get the details of the group owner as a `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pDevice` object |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getPassphrase()() ` Get the passphrase of the group. |
| ` int` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getSecurityType()() ` Get the security type of the group. |
| ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pConnectionInfo` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getWifiP2pGroupClientConnectionInfo()() ` Gets the P2P connection information for this device if it is a client in the group. |
| ` boolean` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#isGroupOwner()() ` Check whether this device is the group owner of the created p2p group |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Implement the Parcelable interface |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/android/os/Parcelable ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | | ` abstract void` | ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. | ||

## Constants

### NETWORK_ID_PERSISTENT

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int NETWORK_ID_PERSISTENT
```

The persistent network id.
If a matching persistent profile is found, use it.
Otherwise, create a new persistent profile.

<br />

**See also:**

- `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getNetworkId()`

Constant Value:

-2
(0xfffffffe)


### NETWORK_ID_TEMPORARY

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int NETWORK_ID_TEMPORARY
```

The temporary network id.

<br />

**See also:**

- `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getNetworkId()`

Constant Value:

-1
(0xffffffff)


### SECURITY_TYPE_UNKNOWN

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SECURITY_TYPE_UNKNOWN
```

The definition of security type unknown. It is set when framework fails to derive the
security type from the authentication key management provided by wpa_supplicant.

<br />

Constant Value:

-1
(0xffffffff)


### SECURITY_TYPE_WPA2_PSK

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SECURITY_TYPE_WPA2_PSK
```

The definition of security type WPA2-PSK.

<br />

Constant Value:

0
(0x00000000)


### SECURITY_TYPE_WPA3_COMPATIBILITY

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SECURITY_TYPE_WPA3_COMPATIBILITY
```

The definition of security type WPA3-Compatibility Mode.

<br />

Constant Value:

1
(0x00000001)


### SECURITY_TYPE_WPA3_SAE

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SECURITY_TYPE_WPA3_SAE
```

The definition of security type WPA3-SAE.

<br />

Constant Value:

2
(0x00000002)


## Fields

### CREATOR

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<WifiP2pGroup> CREATOR
```

Implement the Parcelable interface

<br />

## Public constructors

### WifiP2pGroup

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public WifiP2pGroup ()
```

<br />

<br />

### WifiP2pGroup

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public WifiP2pGroup (WifiP2pGroup source)
```

copy constructor

<br />

| Parameters ||
|---|---|
| `source` | `WifiP2pGroup` <br /> |

## Public methods

### describeContents

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

Implement the Parcelable interface

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### getClientList

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Collection<WifiP2pDevice> getClientList ()
```

Get the list of clients currently part of the p2p group

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pDevice>` | <br /> |

### getFrequency

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getFrequency ()
```

Get the operating frequency (in MHz) of the p2p group

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getGroupOwnerBssid

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MacAddress getGroupOwnerBssid ()
```

Returns the BSSID, if this device is the group owner of the P2P group supporting Wi-Fi
Direct R2 protocol.


The interface address of a Wi-Fi Direct R2 supported device is randomized. So for every
group owner session a randomized interface address will be returned.


The BSSID returned will be `null`, if this device is a client device or a group owner
which doesn't support Wi-Fi Direct R2 protocol.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/MacAddress` | the BSSID. <br /> |

### getInterface

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getInterface ()
```

Get the interface name on which the group is created

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getNetworkId

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getNetworkId ()
```

The network ID of the P2P group in wpa_supplicant.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getNetworkName

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getNetworkName ()
```

Get the network name (SSID) of the group. Legacy Wi-Fi clients will discover
the p2p group using the network name.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getOwner

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public WifiP2pDevice getOwner ()
```

Get the details of the group owner as a `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pDevice` object

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pDevice` | <br /> |

### getPassphrase

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getPassphrase ()
```

Get the passphrase of the group. This function will return a valid passphrase only
at the group owner. Legacy Wi-Fi clients will need this passphrase alongside
network name obtained from `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#getNetworkName()` to join the group

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getSecurityType

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSecurityType ()
```

Get the security type of the group.

<br />

| Returns ||
|---|---|
| `int` | One of the `SECURITY_TYPE_*`. Value is one of the following: - `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#SECURITY_TYPE_UNKNOWN` - `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#SECURITY_TYPE_WPA2_PSK` - `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#SECURITY_TYPE_WPA3_COMPATIBILITY` - `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pGroup#SECURITY_TYPE_WPA3_SAE` |

### getWifiP2pGroupClientConnectionInfo

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public WifiP2pConnectionInfo getWifiP2pGroupClientConnectionInfo ()
```

Gets the P2P connection information for this device if it is a client in the group.
If this device is the Group Owner, this will return `null`.


To get the most up-to-date information, an application should listen for the
`https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager#WIFI_P2P_CONNECTION_CHANGED_ACTION` broadcast. When this device joins a
group as a client, the system updates the connection information and broadcasts the new
group details in the `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager#EXTRA_WIFI_P2P_GROUP` extra.


Alternatively, an application can call `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager#requestGroupInfo(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pManager.GroupInfoListener)` to get the
latest group details.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pConnectionInfo` | A `https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pConnectionInfo` object if this device is a client, or `null` if it is the Group Owner. <br /> |

### isGroupOwner

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isGroupOwner ()
```

Check whether this device is the group owner of the created p2p group

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### toString

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### writeToParcel

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Implement the Parcelable interface

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: The Parcel in which the object should be written. This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |