Simple Android library to notify Android device network changes and react properly.

Preview GIF



  • Detects internet connection changes(Connect / Disconnect)
  • Alerts user via a customizable status-bar notification message on connection loos / hides it on connection regain
  • Asks for a direct connection(Ping) to a reliable CDN(changeable IP address) to make sure user connected to internet
  • Checks connectivity periodically (duration calculated automatically)
  • Handles app close and open states
  • Changeable messages and drawables


Step 1. Add this in your root build.gradle at the end of repositories:

allprojects {
		repositories {
			maven { url '' }

Step 2. Add the dependency

dependencies {
           implementation 'com.github.draxdave:netWatch:0.d.6'

Step 3. Register NetWatch

Add below code inside base activity or Application class

                .setCallBack(new NetworkChangeReceiver_navigator() {
                    public void onConnected(int source) {
                        // do some thing

                    public void onDisconnected() {
			// do some other thing

Available options

  • setIcon : Statusbar notification drawable graphic
  • setCallBack : onConnect and onDisconnect callbacks
  • setMessage : Statusbar notification message
  • setNotificationCancelable : Statusbar notification cancelable
  • setNotificationEnabled : Show statusbar notification on disconnect from internet
  • setNotificationBuilder : Create your own statusbar notification to show
  • unregister : disable NetWatch

Extra configs

Target server IP address

Add following line inside string.xml file :

<string name="netwatch_target_ping_server_ip_add"></string>

Disconnect message text

Add following line inside string.xml file :

<string name="netwatch_lost_connection">No internet connection</string>

Final speech

Feel free to engage!
This tiny library have a lot to do obviously . So help it if you liked it.
There is always better solutions and libraries so search more and you'll found a better code.
Correct my mistakes and rewrite them in case you found some thing better or a more convenient way to handle issues.