@Override public void onReceive(Context context, Intent intent) { receiver = NetworkStateReceiver.this; if (intent.getAction().equalsIgnoreCase(ANDROID_NET_CHANGE_ACTION) || intent.getAction().equalsIgnoreCase(TA_ANDROID_NET_CHANGE_ACTION)) { Logger.i(NetworkStateReceiver.this, "ÍøÂç״̬¸Ä±ä."); if (!NetWorkUtil.isNetworkAvailable(context)) { Logger.i(NetworkStateReceiver.this, "ûÓÐÍøÂçÁ¬½Ó."); networkAvailable = false; } else { Logger.i(NetworkStateReceiver.this, "ÍøÂçÁ¬½Ó³É¹¦."); netType = NetWorkUtil.getAPNType(context); networkAvailable = true; } notifyObserver(); } }
/** * ×¢ÏúÍøÂç״̬¹ã²¥ * * @param mContext */ public static void unRegisterNetworkStateReceiver(Context mContext) { if (receiver != null) { try { mContext.getApplicationContext().unregisterReceiver(receiver); } catch (Exception e) { Logger.d("TANetworkStateReceiver", e.getMessage()); } } }