1. Check out our companion app, Forums for Android! Download from Google Play

ROAMING on Android, has anyone ever worked with it???

Discussion in 'Application Development' started by gumatias, Mar 23, 2010.

  1. gumatias

    gumatias Member
    Thread Starter

    Dec 4, 2009
    Java Developer
    Hello guys,

    I'm working on a project that I need to know whether the device is on
    roaming or not. I've been digging until the very last page of Google
    without success, I haven't found any sample code of how to accomplish

    This is the far that I could go:

    ServiceState ss = new ServiceState();
    Log.i(TAG, "roaming 1: " + ss.getRoaming());
    Log.i(TAG, "roaming 2: " + ss.getOperatorAlphaLong());
    Log.i(TAG, "roaming 3: " + ss.getOperatorAlphaShort());
    Log.i(TAG, "roaming 4: " + ss.getOperatorNumeric());
    Log.i(TAG, "roaming 5: " + ss.getState());

    and it results:

    roaming 1: false
    roaming 2: null
    roaming 3: null
    roaming 4: null
    roaming 5: 1

    I have no idea what the snippet bellow is for, but I decided to add it
    into my Manifest file just in case:

    android:name="android.permission.ACCESS_COARSE_LOCATION" />
    android:name="android.permission.ACCESS_COARSE_UPDATES" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" /

    Can any of you guys help me on this one?

    PS: I'm testing it on my Droid, and I've got plenty of SIM Cards from
    other countries and cities so that I can get the roaming status to be




  2. gumatias

    gumatias Member
    Thread Starter

    Dec 4, 2009
    Java Developer
    Just figured that out! I realized that I was trying to work with the wrong classes... here is a sample code that I placed in my onCreate method to check the roaming status:

    TelephonyManager tm = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);

    // roaming is off
    } else if (tm.getSimCountryIso().equals(tm.getNetworkCountryIso())) {
    // national roaming
    } else {
    // international roaming

    I'm not completely sure about this national and international roaming stuff, but I've tried with many kind of SIM cards and they all seemed to work perfectly!

    Hope it'll help those that got into the same difficulty I did.


Share This Page