Auto Network detect using Broadcast receiver

348 views.

When using application suddenly if the network is OFF or ON we can detect using the broadcast receiver.

Please refer below code for that

step1: Create one class that extends as an application like below

TestApp.Java

Step2:

Add that class name in the manifest file within Application tag like below

Step3:

Create one more class on name of NetworkConnectvity.Java that extends as a broadcast receiver

Step4:

Finally which class you want to check internet automatically add like below

 

You may also like...

Leave a Reply