android - nullpointer exception on connectivitymanager -


public boolean isonline() {     connectivitymanager cm = (connectivitymanager) getsystemservice(context.connectivity_service);     return cm.getactivenetworkinfo().isconnectedorconnecting();} 

i'm getting nullpointer on return cm.getactivenetworkinfo.

i tried this.getsystemservice didn't work. maybe because activity extends super activity i've created , i'm grabbing context incorrectly...? tried getbasecontext() too

with 2 methods chained on return line, sure it's connectivitymanager coming null? it's valid connectivitymanager.getactivenetworkinfo() return null instead of valid networkinfo object when there no active network. if comes null, call networkinfo.isconnectedorconnecting() throwing exception.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -