public class ConnectivityReceiver
extends BroadcastReceiver
When instantiating ConnectivityReceiver, you have the option to set a connectedFlag. You can override the connectivity value reported by the system by setting this flag to true or false. If left in its default value (null), ConnectivityReceiver will report the system value.
ConnectivityReceiver also lets you subscribe to connecitivity changes using a ConnectivityListener.
Constructor and Description |
---|
ConnectivityReceiver(Context context)
ConnectivityReceiver constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectivityListener(com.mapbox.android.core.connectivity.ConnectivityListener listener) |
java.lang.Boolean |
getConnectedFlag()
Get the connectedFlag value
|
boolean |
isConnected()
Get the connectivity state.
|
static boolean |
isConnected(Context context)
Get the connectivity state as reported by the Android system
|
void |
onReceive(Context context,
Intent intent) |
boolean |
removeConnectivityListener(com.mapbox.android.core.connectivity.ConnectivityListener listener) |
void |
removeConnectivityUpdates() |
void |
requestConnectivityUpdates() |
void |
setConnectedFlag(java.lang.Boolean connectedFlag)
Set the connectedFlag value
|
public ConnectivityReceiver(Context context)
context
- Android context. To avoid memory leaks, you might want to pass the application
context and make sure you call removeConnectivityUpdates() when you don't need
further updates (https://github.com/mapbox/mapbox-gl-native/issues/7176)public static boolean isConnected(Context context)
context
- Android contextpublic boolean isConnected()
public java.lang.Boolean getConnectedFlag()
public void setConnectedFlag(java.lang.Boolean connectedFlag)
connectedFlag
- Set it to true/false to override the connectivity statepublic void addConnectivityListener(com.mapbox.android.core.connectivity.ConnectivityListener listener)
public boolean removeConnectivityListener(com.mapbox.android.core.connectivity.ConnectivityListener listener)
public void requestConnectivityUpdates()
public void removeConnectivityUpdates()
public void onReceive(Context context, Intent intent)
© 2017–2018 Mapbox. All rights reserved.