public class ConnectivityReceiver
extends BroadcastReceiver
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activates the connectivity receiver.
|
void |
addListener(ConnectivityListener listener)
Add a listener to be notified
|
void |
deactivate()
Deactivates the connectivity receiver.
|
static ConnectivityReceiver |
instance(Context context)
Get a single instance of ConnectivityReceiver.
|
boolean |
isConnected(Context context)
Get current connectivity state
|
void |
onReceive(Context context,
Intent intent) |
void |
removeListener(ConnectivityListener listener)
Remove a listener
|
public static ConnectivityReceiver instance(Context context)
context
- the context to extract the application context frompublic void activate()
if the underlying connectivity receiver isn't active, register the connectivity receiver.
public void deactivate()
if no other components are listening, unregister the underlying connectivity receiver.
public void onReceive(Context context, Intent intent)
public void addListener(ConnectivityListener listener)
listener
- the listener to addpublic void removeListener(ConnectivityListener listener)
listener
- the listener to removepublic boolean isConnected(Context context)
context
- current Context© 2015–2018 Mapbox. All rights reserved.