how to get country phone prefix from iso

后端 未结 4 2089
梦如初夏
梦如初夏 2020-11-30 08:20

I got the country iso by the code from this answer:

TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryCode         


        
4条回答
  •  一整个雨季
    2020-11-30 08:43

    Copied from Here

     /**
         * network iso code: referred and listed at:
         * http://en.wikipedia.org/wiki/List_of_mobile_country_codes
         */
          TelephonyManager manager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
        String DEVICE_COUNTRY = manager.getNetworkCountryIso();
    

    Update:: Copied from here

    String locale = getApplicationCOntext().getResources().getConfiguration().locale.getCountry();
    

提交回复
热议问题