How to listen to WifiMonitor events
My question is about detecting that my cellphone wifi connection is bound to a network and is operationnal.
I Can see such a line in the LogCat (tagged "WifiMonitor")
VERBOSE/WifiMonitor(93): Event [CTRL-EVENT-CONNECTED - Connection to c4:3d:c7:89:cf:c0 completed (auth) [id=8 id_str=]]
Tha开发者_运维问答t did let me hope that event was catchable... But How ?
Thank your for attention.
You should have a look at the ConnectivityManager: ConnectivityManager
And
public boolean isWifiOnline() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
return true;
}
return false;
}
精彩评论