Obtaining a country code

I am implementing in app purchase. In the product list in the application, I configured several products for country A and several products for country B. Therefore, in my application, only those products that are configured for country A for the user in country A and in the same way for the user in country B should be displayed. Therefore, when my application interacts with my content server, the application should be able to send the country of the device with server requests. How can I achieve this?

I used the TelephonyManager: getNetworkCountryIso () method to get the mobile country code (MCC). But the documentation says: "Only when the user is logged on to the network. The result may be unreliable on CDMA networks." Also, when I tried this,

  • on Samsung devices (2.3) with Wi-Fi, no sim, I got a code
  • on a samsung device (2.3) with sim, without an internet connection, I received a code
  • on lg (2.2) with wifi, no sim i got the code
  • xperia x10 (2.1) with Wi-Fi, no sim .. I did not receive the code
  • xperia x10 (2.3) with sim, with internet connection .. i got the code

Everything where gsm. I cannot understand why I could not get mcc for the 4th case?

Also, how does Google determine the country of a device to filter applications on the market?

Any idea?

Edit: I tried in Dell Venue (2.2) with Wi-Fi, without sim: I did not get MCC

+4
source share
1 answer

I think google checks how getSimCountryIso . This is generally reliable. But I may be wrong

+5
source

Source: https://habr.com/ru/post/1390493/


All Articles