How to format a phone number using PhoneNumberUtils?

前端 未结 8 1915
慢半拍i
慢半拍i 2020-12-07 22:05

How can I format a phone number using PhoneNumberUtils?

E.g.: 1234567890(123) 456-7890

8条回答
  •  佛祖请我去吃肉
    2020-12-07 22:59

    2020 working sulotion:

    TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    
    String countryIso = telephonyManager.getNetworkCountryIso().toUpperCase();              //important!!
    
    phoneNumberTextView.setText(PhoneNumberUtils.formatNumber("3473214567", countryIso));
    

提交回复
热议问题