Example usage for android.net ConnectivityManager getNetworkPreference

List of usage examples for android.net ConnectivityManager getNetworkPreference

Introduction

In this page you can find the example usage for android.net ConnectivityManager getNetworkPreference.

Prototype

@Deprecated
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
public int getNetworkPreference() 

Source Link

Document

Retrieves the current preferred network type.

Usage

From source file:org.restcomm.app.qoslib.Services.LibPhoneStateListener.java

@SuppressLint("InlinedApi")
@SuppressWarnings("deprecation")
public int networkPreference(Context context) {

    String pref = null;/*from w  w  w. j a  v a  2s. co  m*/
    ConnectivityManager con = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    int attemptTwo = con.getNetworkPreference();

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return Settings.System.getInt(context.getContentResolver(), Settings.System.NETWORK_PREFERENCE, 0);
    } else {
        return Settings.Global.getInt(context.getContentResolver(), Settings.Global.NETWORK_PREFERENCE, 0);
    }
}