开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜