Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager#nestedclasses) \| [Methods](https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager#inhmethods)

# ConnectivityDiagnosticsManager

*** ** * ** ***


`
public


class
ConnectivityDiagnosticsManager
`


`

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


`

`


`

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

<br />

*** ** * ** ***

Class that provides utilities for collecting network connectivity diagnostics information.
Connectivity information is made available through triggerable diagnostics tools and by listening
to System validations. Some diagnostics information may be permissions-restricted.

ConnectivityDiagnosticsManager is intended for use by applications offering network
connectivity on a user device. These tools will provide several mechanisms for these applications
to be alerted to network conditions as well as diagnose potential network issues themselves.

The primary responsibilities of this class are to:

- Allow permissioned applications to register and unregister callbacks for network event notifications
- Invoke callbacks for network event notifications, including:
  - Network validations
  - Data stalls
  - Connectivity reports from applications

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback` Abstract base class for Connectivity Diagnostics callbacks. |
| ` class` | `https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager.ConnectivityReport` Class that includes connectivity information for a specific Network at a specific time. |
| ` class` | `https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager.DataStallReport` Class that includes information for a suspected data stall on a specific Network |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager#registerConnectivityDiagnosticsCallback(android.net.NetworkRequest,%20java.util.concurrent.Executor,%20android.net.ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback)(https://developer.android.com/reference/android/net/NetworkRequest request, https://developer.android.com/reference/java/util/concurrent/Executor e, https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback callback) ` Registers a ConnectivityDiagnosticsCallback with the System. |
| ` void` | ` https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager#unregisterConnectivityDiagnosticsCallback(android.net.ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback)(https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback callback) ` Unregisters a ConnectivityDiagnosticsCallback with the System. |

| ### 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*. | ||

## Public methods

### registerConnectivityDiagnosticsCallback

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

```
public void registerConnectivityDiagnosticsCallback (NetworkRequest request, 
                Executor e, 
                ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback callback)
```

Registers a ConnectivityDiagnosticsCallback with the System.

Only apps that offer network connectivity to the user should be registering callbacks.
These are the only apps whose callbacks will be invoked by the system. Apps considered to
meet these conditions include:

- Carrier apps with active subscriptions
- Active VPNs
- WiFi Suggesters

Callbacks registered by apps not meeting the above criteria will not be invoked.

If a registering app loses its relevant permissions, any callbacks it registered will
silently stop receiving callbacks. Note that registering apps must also have location
permissions to receive callbacks as some Networks may be location-bound (such as WiFi
networks).

Each register() call **MUST** use a ConnectivityDiagnosticsCallback instance that is
not currently registered. If a ConnectivityDiagnosticsCallback instance is registered with
multiple NetworkRequests, an IllegalArgumentException will be thrown.

To avoid performance issues due to apps leaking callbacks, the system will limit the
number of outstanding requests to 100 per app (identified by their UID), shared with
callbacks in `https://developer.android.com/reference/android/net/ConnectivityManager`. Registering a callback with this method will count
toward this limit. If this limit is exceeded, an exception will be thrown. To avoid hitting
this issue and to conserve resources, make sure to unregister the callbacks with
`https://developer.android.com/reference/android/net/ConnectivityDiagnosticsManager#unregisterConnectivityDiagnosticsCallback(android.net.ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback)`.

<br />

| Parameters ||
|---|---|
| `request` | `NetworkRequest`: The NetworkRequest that will be used to match with Networks for which callbacks will be fired. This value cannot be `null`. <br /> |
| `e` | `Executor`: The Executor to be used for running the callback method invocations. This value cannot be `null`. <br /> |
| `callback` | `ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback`: The ConnectivityDiagnosticsCallback that the caller wants registered with the System. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the same callback instance is registered with multiple NetworkRequests |
| `https://developer.android.com/reference/java/lang/RuntimeException` | if the app already has too many callbacks registered. |

### unregisterConnectivityDiagnosticsCallback

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

```
public void unregisterConnectivityDiagnosticsCallback (ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback callback)
```

Unregisters a ConnectivityDiagnosticsCallback with the System.

If the given callback is not currently registered with the System, this operation will be
a no-op.

<br />

| Parameters ||
|---|---|
| `callback` | `ConnectivityDiagnosticsManager.ConnectivityDiagnosticsCallback`: The ConnectivityDiagnosticsCallback to be unregistered from the System. This value cannot be `null`. <br /> |