Question

In Android, checking internet connection is like that.

public boolean isOnline() {
    ConnectivityManager cm = (ConnectivityManager) activity
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();

    if (netInfo != null && netInfo.isConnectedOrConnecting()) {
        return true;
    }
    return false;
}

How about in Blackberry RIM?

p/s*: I am not asking for checking the type of connection or connection available.

Was it helpful?

Solution

For instance, to check only for BIS coverage:

boolean hasConnectivity = TransportInfo.isTransportTypeAvailable(TransportInfo.TRANSPORT_BIS_B) && TransportInfo.hasSufficientCoverage(TransportInfo.TRANSPORT_BIS_B);

You have more flags available in TransportInfo class for Wi-Fi, BES (MDS) and direct TCP. So the method to check for internet connectivity would check for all the available transport types.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top