2015-11-25 68 views

回答

1

您可以使用電話管理器或使用IP地址獲取當前的ISO2國家/地區代碼。然後使用區域設置獲取ISO3國家/地區代碼。

下面是示例:

TelephonyManager tm = (TelephonyManager)getSystemService(getApplicationContext().TELEPHONY_SERVICE); 
    String countryCode = tm.getNetworkCountryIso(); 
    String currentISO3CountryCode = new Locale("", countryCode).getISO3Country(); 

另外這裏是讓所有國家的ISO3代碼示例:

for (String country : Locale.getISOCountries()) { 
     Locale locale = new Locale("", country); 
     Log.v(TAG, "ISO3 country code: " + locale.getISO3Country().toUpperCase()); 
    } 
相關問題