接着,我收到了以下网站:。 它是完美的。 我能够与我的当地乌菲联系。
But, I really want the current status of the wifi, I am using following code to get the status of wifi. But unfortunately I am only able to get DISABLED , ENABLED and SCANNING status, I really want to receive other intermediary states.
你可以告诉我我我,我是错了。
public class ConnectionChangeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
Message msg = new Message();
msg.what = 5;
Bundle b = new Bundle();
String sStatus = "UnKnown";
switch(info.getDetailedState()){
case AUTHENTICATING:
sStatus = "Authenticating...";
break;
case CONNECTED:
sStatus = "Connected";
break;
case CONNECTING:
sStatus = "Connecting...";
break;
case DISCONNECTED:
sStatus = "Disconnected";
break;
case DISCONNECTING:
sStatus = "Disconnecting...";
break;
case FAILED:
sStatus = "Failed";
break;
case IDLE:
sStatus = "Idle";
break;
case OBTAINING_IPADDR :
sStatus = "Obtaining IP Address...";
break;
case SCANNING:
sStatus = "Scanning...";
break;
case SUSPENDED:
sStatus = "Suspended";
break;
}
b.putString("status", sStatus);
msg.setData(b);
mHandler.sendMessage(msg);
}
}
I register the broadcast receiver in the following way
IntentFilter filter = new IntentFilter(
ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(networkStateReceiver, filter);