How can I get the country (or its ISO code)?

后端 未结 9 1419
忘了有多久
忘了有多久 2020-12-04 17:32

What is the best way to get the country code?

As of now, I know two ways. One is to get by TelephonyManager and another by Locale. Which is another best and unique wa

9条回答
  •  死守一世寂寞
    2020-12-04 18:11

    You can use this code to get ISO 2:

    Locale.getDefault().getCountry()
    

    And this to get ISO 3:

    Locale.getDefault().getISO3Country()
    

提交回复
热议问题