Class NetworkTypeObserver
- java.lang.Object
-
- com.google.android.exoplayer2.util.NetworkTypeObserver
-
public final class NetworkTypeObserver extends Object
Observer for network type changes.Registeredlisteners are informed at registration and whenever the network type changes.The current network type can also be
queriedwithout registration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNetworkTypeObserver.ConfigConfiguration forNetworkTypeObserver.static interfaceNetworkTypeObserver.ListenerA listener for network type changes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NetworkTypeObservergetInstance(Context context)Returns a network type observer instance.intgetNetworkType()Returns the current network type.voidregister(NetworkTypeObserver.Listener listener)Registers a listener.static voidresetForTests()Resets the network type observer for tests.
-
-
-
Method Detail
-
getInstance
public static NetworkTypeObserver getInstance(Context context)
Returns a network type observer instance.- Parameters:
context- AContext.
-
resetForTests
public static void resetForTests()
Resets the network type observer for tests.
-
register
public void register(NetworkTypeObserver.Listener listener)
Registers a listener.The current network type will be reported to the listener after registration.
- Parameters:
listener- TheNetworkTypeObserver.Listener.
-
getNetworkType
@NetworkType public int getNetworkType()
Returns the current network type.
-
-