androidtelephonyroaming

Differentiate between international roaming and roaming with the country.


Do we have any flag or value on the phone which can help decide this ?


Solution

  • 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.

    ---- 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
    }