利用com.google.i18n.phonenumbers.PhoneNumberUtil获取手机国家地区区号

pom中
       
            com.googlecode.libphonenumber
            libphonenumber
            8.0.0
       

build.gradle

    implementation 'com.googlecode.libphonenumber:libphonenumber:8.0.0'

 

 

 

    public static void main(String[] args) {

        String[] countries = Locale.getISOCountries();
        for (int i = 0; i < countries.length; i++)
        {
            String code=countries[i];
            Locale locale = new Locale("zh", code);
            String mDisplayName=locale.getDisplayName();
            mDisplayName=mDisplayName.substring(mDisplayName.indexOf("("),mDisplayName.indexOf(")"));
            System.out.println("+"+ PhoneNumberUtil.getInstance().getCountryCodeForRegion(code)      +"        "+mDisplayName);
        }

    }

 

你可能感兴趣的:(安卓,Java程序设计,框架)