我有这个 BroadCastReceiver 来监听WiFi
状态的变化:
private BroadcastReceiver mWifiStateChangedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int extraWifiState = intent.getIntExtra(
WifiManager.EXTRA_WIFI_STATE,
WifiManager.WIFI_STATE_UNKNOWN
);
wifiState = new WifiState(Main.this);
switch (extraWifiState) {
case WifiManager.WIFI_STATE_DISABLED:
wifiState.haveNetworkConnection();
break;
case WifiManager.WIFI_STATE_ENABLED:
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
while (conMan.getActiveNetworkInfo() == null
|| conMan.getActiveNetworkInfo().getState() != NetworkInfo.State.CONNECTED) {
wifiState.cancelDialog();
}
break;
case WifiManager.WIFI_STATE_ENABLING:
break;
case WifiManager.WIFI_STATE_UNKNOWN:
break;
}
}
};
如何在此广播接收器中添加对收听移动数据的支持?
提前谢谢各位!