实时获得机器network的状态
IntentFilter mNetworkStateChangedFilter = new IntentFilter();mNetworkStateChangedFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);mNetworkStateIntentReceiver = new BroadcastReceiver() {@Overridepublic void onReceive(Context context, Intent intent) {if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {boolean down = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);//对network的up or down 进行处理onNetworkToggle(!down);}}};registerReceiver(mNetworkStateIntentReceiver,mNetworkStateChangedFilter);