ReactiveWiFi
ReactiveWiFi copied to clipboard
Question about detecting no internet connection in WiFi access point
Is the library able to detect when Android device is connected to WiFi AP but the access point has just lost the internet connection?
I want to react on such case and e.g show WiFi icon with exclamation mark (like on native status bar)
Yes, it's possible, but not with this library :). ReactiveWiFi is dedicated just to monitoring available WiFi APs around. If you want to detect a situation when device is connected to the WiFi or Internet or both or connection is lost, you can have a look at ReactiveNetwork library, which is my another project. Especially, you can have a look at Chaining network and Internet connectivity streams section in the documentation. In your case, you may need flatMap(...) operator instead of flatMapSingle(...) if you want to observe internet and network connectivity continuously.
@pwittchen Yes, but I assume i still need to subscribe to two observables:
ReactiveNetwork.observeInternetConnectivity()
and
ReactiveNetwork.observeNetworkConnectivity(applicationContext)
I've just thought it would be nice to have this ability in one Observable of the library API of yours
Library does not provide such observable because different users have different use cases and I don't know if there's general solution for that. You can combine these two observables into one using flatMap(...) like in the example I linked above. Then you can subscribe it only once. You can adjust this example to your needs and within the flatMap(...) operator return e.g. network type and boolean value indicating if device is connected to the internet (not only the boolean like in the example).