Handle No Internet Connectivity in Android Activity

No Internet

Anu S Pillai

The Admin at GadgetSaint.com

You may also like...

4 Responses

  1. Geevarughese Biji says:

    Hi , It was a nice tutorial, but will it detect limited internet connection(which means Wifi or network is connected,but no internet ) ,,?

  2. Anu S Pillai says:

    I think it wont detect limited internet connection. I will check if I can find some solutions.

  3. Anonymous says:

    My receiver is not called

  4. Lamesh Ramdani says:

    Used the codes as described. Except checkConnection(); , ‘ve called it in my own created activity which is a menu with 3 buttons.
    Why am i getting this error? i’m totally new to android. Thank you.

    FATAL EXCEPTION: main
    Process: com.example.dell.googlemapapps, PID: 12139
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dell.googlemapapps/com.example.dell.AQMS.MenuActivity}: java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.Context android.content.ContextWrapper.getApplicationContext()’ on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.Context android.content.ContextWrapper.getApplicationContext()’ on a null object reference
    at com.example.dell.AQMS.ConnectionReceiver.isConnected(ConnectionReceiver.java:31)
    at com.example.dell.AQMS.MenuActivity.checkConnection(MenuActivity.java:102)
    at com.example.dell.AQMS.MenuActivity.onCreate(MenuActivity.java:28)
    at android.app.Activity.performCreate(Activity.java:6955)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
    at android.app.ActivityThread.-wrap14(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6776) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 

Leave a Reply

Your email address will not be published.