• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

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

gumatias

Lurker
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
that.

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:

<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
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
on.

Regards

-gustavo
 
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);

if(!tm.isNetworkRoaming()){
// 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.

Cheers!
 
Back
Top Bottom