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 |
|---|
interface NetworkTypeObserver.ListenerA 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""])This function is deprecated. Use |
Unit |
register(listener: NetworkTypeObserver.Listener!, executor: Executor!)Registers a listener. |
synchronized java-static Unit |
Resets the network type observer for tests. |
Public properties |
|
|---|---|
Int |
@GuardedBy(value = "lock") |
Public functions
getInstance
synchronized java-static fun getInstance(context: Context!): NetworkTypeObserver!
Returns a network type observer instance.
register
@InlineMe(replacement = "this.register(listener, new Handler(Looper.getMainLooper())::post)", imports = [""android.os.Handler"", ""android.os.Looper""])
funregister(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 |
executor: Executor! |
The |
resetForTests
@VisibleForTesting
synchronized java-static fun resetForTests(): Unit
Resets the network type observer for tests.