Skip to content

PikeYe/ConnectionCheckUtil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConnectionCheckUtil

Check the network connection(a few DNS) with RxJava2

If you want to check the mobile network to see whether it is connected, you can try to call a few DNS with this tool. When calling,

  • If one of the DNS is success, then the tool will callback at once, not need to wait for all the DNS success.
  • Only when all the DNS are fail to connect, will the callback be called.

1.In the application, handle the extra exception in RxJava that when the Observer is dispose

ConnectionCheckUtil.initRxJavaDisposeErrorHandler()

2.Use the tool like this way:

ConnectionCheckUtil.connectionCheck(object : OnConnectionCheckListener {
            override fun onConnected() {
                //connected
            }
            override fun onDisconnected() {
                //not connected
            }
        })

CSDN Blog Site

About

Check the network connection(a few DNS) with RxJava2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors