Example usage for android.net NetworkInfo getDetailedState

List of usage examples for android.net NetworkInfo getDetailedState

Introduction

In this page you can find the example usage for android.net NetworkInfo getDetailedState.

Prototype

@Deprecated
public @NonNull DetailedState getDetailedState() 

Source Link

Document

Reports the current fine-grained state of the network.

Usage

From source file:com.newsrob.EntryManager.java

public boolean isNetworkConnected(Context ctx) {

    if (connectivityManager == null)
        connectivityManager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
    if (ni == null) {
        PL.log("EntryManager. Wasn't able to get NI.", ctx);
        return false;
    }//from  ww  w.java2  s .  c  om

    if (NewsRob.isDebuggingEnabled(ctx)) {
        PL.log("ActiveNetwork: " + ni.getTypeName(), ctx);
        PL.log("ActiveNetworkState: " + ni.getDetailedState(), ctx);
        PL.log("isNetworkConnected? " + ni.isConnected(), ctx);
    }

    return ni.isConnected();
}

From source file:com.grazerss.EntryManager.java

public boolean isNetworkConnected(Context ctx) {

    if (connectivityManager == null) {
        connectivityManager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
    }//from w  ww . j  av a 2s .  c o m

    NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
    if (ni == null) {
        PL.log("EntryManager. Wasn't able to get NI.", ctx);
        return false;
    }

    if (NewsRob.isDebuggingEnabled(ctx)) {
        PL.log("ActiveNetwork: " + ni.getTypeName(), ctx);
        PL.log("ActiveNetworkState: " + ni.getDetailedState(), ctx);
        PL.log("isNetworkConnected? " + ni.isConnected(), ctx);
    }

    return ni.isConnected();
}