*> connectivity.getActiveNetworkInfo() returns null if there is no connection. Hence when you call .isConnected() on that, it throws null pointer exception.*
No, that is not it... He checks to make sure that connectivity.getActiveNetworkInfo() is not null before he calls the other methods... What does logcat say exactly regarding the null pointer exception? Specifically look for a "caused by" line... Also, I would probably do something like this, but that is just coding preferences (though, it might help you get better info from logcat on the cause of the error): NetworkInfo netInfo = connectivity.getActiveNetworkInfo(); boolean valid = netInfo != null && netInfo.isAvailable() && netInfo.isConnected(); Have you made sure that your connectivity variable is not null? Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Tue, Jul 5, 2011 at 10:33 PM, Sourav Howlader <sourav.howla...@gmail.com>wrote: > Hi vani, > > connectivity.getActiveNetworkInfo() returns null if there is no > connection. > Hence when you call .isConnected() on that, it throws null pointer > exception. > > Regards, > Sourav > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en