So... after spending some time reading the documentation I could
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:
Java:
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!
On Mar 23, 1:11 pm, Gustavo <[email protected]> wrote:
> 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
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
To unsubscribe from this group, send email to
android-beginners+unsubscribegooglegroups.com or reply to this email with the
words "REMOVE ME" as the subject.