观察网络毗连:
ReactiveNetwork .observeNetworkConnectivity(context) .subscribeOn(Schedulers.io()) ... // anything else what you can do with RxJava .observeOn(AndroidSchedulers.mainThread()) .subscribe(connectivity -> { // do something with connectivity // you can call connectivity.state(); // connectivity.type(); or connectivity.toString(); });连续观察互联网毗连:
ReactiveNetwork .observeInternetConnectivity() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(isConnectedToInternet -> { // do something with isConnectedToInternet value });与OkHttp一起集成