List of usage examples for android.telephony TelephonyManager isNetworkRoaming
public boolean isNetworkRoaming()
From source file:com.sonetel.ui.dialpad.DialerFragment.java
protected boolean isRoaming() { TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); return tm.isNetworkRoaming(); }
From source file:org.restcomm.app.utillib.Reporters.ReportManager.java
/** * If MCC and MNC are known, returns them, and updates {@link ReportManager#lastknownMCCMNC}.<br> * If MCC and MNC are unknown and the phone is not roaming, returns {@link ReportManager#lastknownMCCMNC}.<br> * If MCC and MNC are unknown and the phone is roaming, returns <code>{0, 0}</code>. * @return int[] where element 0 is MCC, element 1 is MNC */// ww w .j a va 2s . com public int[] getMCCMNC() { TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); //MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "getMCCMNC", "mcc+mnc " + telephonyManager.getNetworkOperator()); try { if (telephonyManager.getNetworkOperator() == null || telephonyManager.getNetworkOperator().length() < 3) { //MMCLogger.logToFile(MMCLogger.Level.WTF, TAG, "getMCCMNC", "no mnc, just " + telephonyManager.getNetworkOperator()); return lastknownMCCMNC; } String mcc = telephonyManager.getNetworkOperator().substring(0, 3); String mnc = "0"; // if (telephonyManager.getNetworkOperator().length() > 3) mnc = telephonyManager.getNetworkOperator().substring(3); int MCC = Integer.parseInt(mcc); mnc = DeviceInfo.fixMNC(mnc); int MNC = Integer.parseInt(mnc); lastknownMCCMNC[0] = MCC; lastknownMCCMNC[1] = MNC; return lastknownMCCMNC; } catch (IndexOutOfBoundsException e) { LoggerUtil.logToFile(LoggerUtil.Level.WTF, TAG, "getMCCMNC", "IndexOutOfBoundsException parsing mcc+mnc: " + e.getMessage() + ", mcc+mnc=" + telephonyManager.getNetworkOperator()); } catch (NumberFormatException e) { LoggerUtil.logToFile(LoggerUtil.Level.WTF, TAG, "getMCCMNC", "NumberFormatException parsing mcc+mnc: " + e.getMessage() + ", mcc+mnc=" + telephonyManager.getNetworkOperator()); } catch (Exception e) { LoggerUtil.logToFile(LoggerUtil.Level.WTF, TAG, "getMCCMNC", "Exception parsing mcc+mnc: " + e.getMessage() + ", mcc+mnc=" + telephonyManager.getNetworkOperator()); } if (telephonyManager.isNetworkRoaming()) { return new int[] { 0, 0 }; } else { return lastknownMCCMNC; } }