is Network Roaming - Android android.net

Android examples for android.net:ConnectivityManager

Description

is Network Roaming

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;

public class Main {

  public static boolean isNetworkRoaming(Context context) {
    ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivity == null) {
    } else {//from   w  ww  . j ava  2 s .co m
      NetworkInfo info = connectivity.getActiveNetworkInfo();
      if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        if (tm != null && tm.isNetworkRoaming()) {
          return true;
        } else {
        }
      } else {
      }
    }
    return false;
  }

}

Related Tutorials