Getting country code

10,401

i think google checks for either getSimCountryIso. This is usually reliable. But i maybe wrong

Share:
10,401
arjoan
Author by

arjoan

An enthusiast!

Updated on August 22, 2022

Comments

  • arjoan
    arjoan over 1 year

    I am implementing In App Purchase.In the in app product list,I have configured few products for country A and few products for country B. So my application should show only those products configured for country A for a user in country A and similarly for user in country B. So when my app communicates with my content server, the app should be able to send the device country with server requests. How can I achieve this?

    I have used TelephonyManager : getNetworkCountryIso () method to get the Mobile Country Code(MCC). But the documentation says "Only when user is registered to a network. Result may be unreliable on CDMA networks" Also, when i tried this,

    1. on Samsung devices(2.3) with wifi internet, no sim, i got the code
    2. on samsung device(2.3) with sim,no internet connectivity, i got the code
    3. on lg (2.2) with wifi, no sim i got the code
    4. xperia x10 (2.1) with wifi internet,no sim .. i did not get the code
    5. xperia x10 (2.3) with sim,with internet conncetion.. i got the code

    All where gsm. I can't figure out why i couldn't get the mcc for 4th case?

    Also, how does google identify the country of the device for filtering applications in market?

    Any idea?

    Edit: I tried in Dell Venue (2.2) with wifi, without sim: i did not get the MCC

  • arjoan
    arjoan over 12 years
    this again is available with SIM. What if i have data connectivity through WiFi. But no sim?
  • nandeesh
    nandeesh over 12 years
    you could get the last know location of user using LocationManager.getLastKnownLocation and then get the country by either using stackoverflow.com/questions/4497728/… or stackoverflow.com/questions/2296377/…