Codii
Codii

Reputation: 873

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=]]

That did let me hope that event was catchable... But How ?

Thank your for attention.

Upvotes: 0

Views: 1694

Answers (1)

Moystard
Moystard

Reputation: 1837

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

Upvotes: 2

Related Questions