转自:http://stackoverflow.com/questions/808560/how-to-detect-the-physical-connected-state-of-a-network-cable-connector You want to look at the nodes in /sys/class/net/ I experimented with mine: Wire Plugged in: eth0/carrier:1eth0/operstate:unknown Wire
Android系统网络连接状态的改变会发一个广播,注册一个广播接收者,实时动态的检测网络状态,及时提醒用户,优化用户体验. 本文仅提供WIFI 状态的检测作为参考,其他网络连接方式请对比WIFI连接作出调整. 首先写一个WifiStateBroadcast类继承BroadcastReceiver,重写onRecevie方法,获取网络连接状态管理器,通过管理器拿到对应的网络信息,得到网络状态,判断网络状态,作出相应的业务逻辑. public class WifiSta