Android library listening network connection state and change of the WiFi signal strength with event bus
NetworkEvents setPingParameters(String host, int port, int timeoutInMs)
NetworkHelper
classOnlineChecker
in OnlineCheckerImpl
class. Now it pings remote host.android.permission.INTERNET
to AndroidManifest.xml
NetworkHelper
class with static method boolean isConnectedToWiFiOrMobileNetwork(context)
README.md
ACCESS_COARSE_LOCATION
permission to AndroidManifest.xml
to be able to scan WiFi access points on Android 6CHANGE_NETWORK_STATE
and INTERNET
permissions from AndroidManifest.xml
, because they're no longer requiredInternetConnectionChangeReceiver
class and its APIWIFI_CONNECTED
status when enableInternetCheck()
method is called. Read more about this change in appropriate section of README.md
file.replaced networkInfo.isConnectedOrConnecting()
with networkInfo.isConnected()
in isOnline(context)
method in OnlineCheckerImpl
class.
withPingUrl(url)
methodwithPingTimeout()
methodwithoutPing()
methodwithoutWifiAccessPointsScan()
methodexample-disabling-ping-and-wifi-scan
app sampleexample-ping-customization
app sampleNetworkHelper
class and moved its method to specific classes with changed scopeBusWrapper
, which is abstraction for Event Bus required by NetworkEvents
objectexample-greenrobot-bus
app sampleenableWifiScan()
methodenableInternetCheck()
methodgetWifiScanResults()
method in WifiSignalStrengthChanged eventgetMobileNetworkType()
method in ConnectivityChanged eventREADME.md
and library codeIn this version, we can customize NetworkEvents
object. E.g. we can set our own ping url and ping timeout:
networkEvents = new NetworkEvents(this, bus)
.withPingUrl("http://www.android.com")
.withPingTimeout(50 * 1000);
We can also disable ping or Wifi Access Points Scan:
networkEvents = new NetworkEvents(this, bus)
.withoutPing()
.withoutWifiAccessPointsScan();
In the main repository, we can find new examples of applications showing how to use these methods.
In addition, internal elements of code (especially NetworkEvents
class) were updated and new unit tests were created.