Android Question Country Codes + Phones Codes

Discussion in 'Android Questions' started by ALBRECHT, Aug 3, 2019.


    ALBRECHT Active Member Licensed User


    I would know if i am in the good way or if exists a better more simple process

    I have an app that use SMS permissions (but not needs PHONE permission)

    To suggest to the user the + Phone code (before the phone numbers) : +33 682000012
    in relation to the Device Country code :

    Dim r As Reflector
    r.Target = r.RunStaticMethod(
    So, i have create a db table "CountryCodePhone" with all Codes : Country Codes + Phones Codes

    273 records like that ( from E.123 : Notation for national and international telephone numbers ):
    there :

    30: GR / 31: NL / 32: BE / 33: FR / 34: ES / 350: GI / 351: PT / 352: LU / 353: IE / 354: IS / 355: AL ...

    as b4x always reserves me good surprises, is there a better way
    (without asking the entire permission of the Phone, to see the phone code of the device)

  2. emexes

    emexes Well-Known Member Licensed User

    Same for me too! :)
    I'm sure there will be a better way, but a roundabout backup Plan B might be to use the current location data, do a reverse lookup to get the address:

    TBH I thought that the telephone code would be included in the returned data, but given that phone numbers nowadays aren't as tied to geography as they used to be... fair enough.
    Shelby likes this.

    ALBRECHT Active Member Licensed User

    yes exactly,

    that's why I think that the standardization table E.123
    (to be updated according to the evolutions of the countries)
    seems to me, to be a more precise solution?

    except that some countries have duplicate codes, for example :

    Russia, i suggest the 5 :
    RU +79: UK
    RU +78: UK
    RU +74: UK
    RU +73: UK
    RU +7: UK

    Kazakhstan, i suggest the 3 :
    KZ +77: KZ
    KZ +76: KZ
    KZ +7: KZ

  4. emexes

    emexes Well-Known Member Licensed User

    Hmm. That might actually be fixable by my next outside-the-box no-phone-permission-needed idea... use IP reverse-geocode service, eg:

    although that service doesn't have country telephone code, but if we can find one that does, then it will likely decode it down to the region country code that is serviced by your user's mobile service provider.

    On a related note, my mobile phone used to default to a location 1000 km away, which I assumed was because that other city was the headquarters and thus nominal location for my phone's service provider. But I tried on that phone just now, and it's got me to under 14 km: the location it returns is the city centre, and I'm out in a suburb of that city.
    Shelby likes this.
  5. emexes

    emexes Well-Known Member Licensed User

    Ask not, and ye shall receive anyway!!!

    I don't know if this works as well everywhere as it does here, but check this out:

    which returns accurate* information for me like:


    including not just the telephone country code, but the telephone area code as well (03 = Victoria and Tasmania). And the weather station (see next post).

    * seems to be based on nominal location of mobile phone service provider, thus 14 km from my actual location, but... still good enough to freak people out. The postcode looked a bit strange, since Victoria postcodes are usually 3000..3999 but I know there are some special cases and so I checked and yep, 8010 is the postcode for... hang on, that's Optus, not Vodafone... let me double-check this on my mobile... ... ... is all good, same info, except for ISP.
    Shelby likes this.
  6. emexes

    emexes Well-Known Member Licensed User

    Last edited: Aug 3, 2019
    Shelby likes this.
  7. emexes

    emexes Well-Known Member Licensed User

    This: has pinned me down to within 4 km in adjoining suburb (not sure about state code = 07 = Queensland, though).

    This: has pinned me down to under 1 km and in correct suburb.

    I think I'm going to stop now - this is getting a bit too close for my liking.

    ps this: provides data in JSON (not telephone country code, but presumably similar is achievable with other sites)

    pps like this: or even which provides link to this:


    Last edited: Aug 3, 2019
    Shelby likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice