Getting country code

arjoan picture arjoan · Jan 11, 2012 · Viewed 10.3k times · Source

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

Answer

nandeesh picture nandeesh · Jan 11, 2012

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