I am developing an application, where there is a need to check internet connection availability as a continuous procees as long as the whole application is running and destroy when application is not in use.
The process should notify me, if internet connection is in reach or gone on internet connection availability. On it’s notification, I will do some task, both for if not available or available.
You can create a
BroadCastReceiverto listen for network changes, then use theConnectivityManagerto check if the connection has been lost.You will need to add these lines in your
AndroidManifest(replacingMyClassNamewith the name of your class, just as you would do for anyActivitydeclared in theAndroidManifest: