android - NetworkInfo.isAvailable() for Ethernet is always false even if Ethernet is available and connected -


here code:

connectivitymanager conman = (connectivitymanager) getsystemservice(context.connectivity_service); networkinfo info = conman.getactivenetworkinfo(); log.e("test","=================info================\n"+info.tostring()); 

the logcat looks like

e/test    ( 2113): =================info================ e/test    ( 2113): networkinfo: type: ethernet[], state: connected/connected, reason:    (unspecified), extra: (none), roaming: false, failover: false, isavailable: false 

do think weird? not available connected...

try code check network connectivity

 public boolean isnetworkonline() { boolean status=false; try{     connectivitymanager cm = (connectivitymanager) getsystemservice(context.connectivity_service);     networkinfo netinfo = cm.getnetworkinfo(0);     if (netinfo != null && netinfo.getstate()==networkinfo.state.connected) {         status= true;     }else {         netinfo = cm.getnetworkinfo(1);         if(netinfo!=null && netinfo.getstate()==networkinfo.state.connected)             status= true;     } }catch(exception e){     e.printstacktrace();       return false; } return status;  }   

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -