public class NetworkHelper
extends java.lang.Object
用于帮助实现 “仅 Wifi 网络播放” 功能。
限定符和类型 | 类和说明 |
---|---|
static interface |
NetworkHelper.OnNetworkStateChangeListener
网络状态监听器。
|
限定符和类型 | 方法和说明 |
---|---|
boolean |
isWifiNetwork()
当前网络是否是 Wifi 网络。
|
boolean |
networkAvailable()
当前网络是否可用。
|
static NetworkHelper |
newInstance(android.content.Context context,
NetworkHelper.OnNetworkStateChangeListener listener)
创建一个新的
NetworkHelper 对象。 |
void |
subscribeNetworkState()
订阅当前网络状态。
|
void |
unsubscribeNetworkState()
取消订阅当前网络状态。
|
public static NetworkHelper newInstance(@NonNull android.content.Context context, @NonNull NetworkHelper.OnNetworkStateChangeListener listener)
NetworkHelper
对象。context
- Context
对象,不能为 nulllistener
- 网络状态监听器,不能为 nullNetworkHelper
对象public boolean networkAvailable()
public boolean isWifiNetwork()
public void subscribeNetworkState()
调用该方法后,当网络状态发生改变时,NetworkHelper.OnNetworkStateChangeListener
监听器会被调用。
public void unsubscribeNetworkState()