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
@InlineMe(replacement = "this.register(listener, new Handler(Looper.getMainLooper())::post)", imports = [""android.os.Handler"", ""android.os.Looper""])
register(listener: NetworkTypeObserver.Listener!)

This function is deprecated.

Use register instead.

Unit

Registers a listener.

synchronized java-static Unit

Resets the network type observer for tests.

Public properties

Int

Public functions

getInstance

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

Returns a network type observer instance.

Parameters
context: Context!

A Context.

register

@InlineMe(replacement = "this.register(listener, new Handler(Looper.getMainLooper())::post)", imports = [""android.os.Handler"", ""android.os.Looper""])
fun register(listener: NetworkTypeObserver.Listener!): Unit

register

fun register(listener: NetworkTypeObserver.Listener!, executor: Executor!): Unit

Registers a listener.

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

Parameters
listener: NetworkTypeObserver.Listener!

The Listener.

executor: Executor!

The Executor to call the listener on.

resetForTests

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

Resets the network type observer for tests.

Public properties

networkType

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