Do we have any flag or value on the phone which can help decide this ?
2 Answers
I think it's not possible, you can just differenciate whether you're using roaming or not, but at least officially I can't find any info about this.
- getRoaming() from
ServiceState
class. - isRoaming() from
NetworkInfo
class. - Roaming detection in StackOverflow.
---- EDIT ----
As probably there's not a built-int method for this, you could simply define and keep an internal list of national telephony companies and see whether the SIM's operator match one of them, in which case you'll be having a national roaming, an international roaming if the current operator is not the same as the SIM's and it's not in your list, or no-roaming if the current operator matches the SIM's operator. The negative thing is that you'd need to keep track of all national operators and add it to the list if there's some new, but that's something that doesn't happen too often (or at least here).
So basically it would be something like this:
TelephonyManager telephMan = ((TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE));
// This will be the current registered operator
String currentOperatorName = telephMan.getNetworkOperatorName();
// This will return the SIM operator
String simOperatorName = telephonyManager.getSimOperatorName();
// Additionally you'll have to keep a list of national operators
ArrayList<String> myCountryOperators = new ArrayList<String();
myCountryOperators.add("...");
myCountryOperators.add("...");
...
if (currentOperatorName.equals(simOperatorName)) {
// No roaming
}
else if (myCountryOperators.contains(currentOperatorName)) {
// National roaming
}
else {
// International roaming
}
-
Thanks, even I knew the same and have not come across any document or text that says we can differentiate. We have this requirement to display an memory resident icon when device is in international roaming. – Divya Y Mar 07 '14 at 01:50
-
Thanks nKn, that's a nice approach. Really appreciate you help here. – Divya Y Mar 08 '14 at 11:05
-
You're welcome. Once you've found a solution for this don't forget to accept the answer that helped you most, both for reputation and feedback purposes as it will help other users to know which answer helped you most – nKn Mar 08 '14 at 11:34
-
Sure will definitely come back and do that. currently my reputation score does not allow me to vote up. – Divya Y Mar 09 '14 at 19:03
if it's a GSM phone, in my opinion is easier to compare the country code set in the SIM card with the country code of network carrier with TelephonyManager.getNetworkCountryIso() and TelephonyManager.getSimCountryIso() If they match you're in same country, otherwise don't. And you don't need to keep a list of names...

- 351
- 1
- 7