NetworkTypeObserver


@UnstableApi
class NetworkTypeObserver


Observer for network type changes.

Registered listeners are informed at registration and whenever the network type changes.

The current network type can also be queried without registration.

Summary

Nested types

A listener for network type changes.

Public functions

synchronized java-static NetworkTypeObserver!
getInstance(context: Context!)

Returns a network type observer instance.

Unit

Registers a listener.

synchronized java-static Unit

Resets the network type observer for tests.

Public properties

Int
@GuardedBy(value = "networkTypeLock")
@C.NetworkType
networkType

Public functions

getInstance

synchronized java-static fun getInstance(context: Context!): NetworkTypeObserver!

Returns a network type observer instance.

Parameters
context: Context!

A Context.

register

fun register(listener: NetworkTypeObserver.Listener!): Unit

Registers a listener.

The current network type will be reported to the listener after registration.

Parameters
listener: NetworkTypeObserver.Listener!

The Listener.

resetForTests

@VisibleForTesting
synchronized java-static fun resetForTests(): Unit

Resets the network type observer for tests.

Public properties

networkType

@GuardedBy(value = "networkTypeLock")
@C.NetworkType
val networkTypeInt