public void init(AttributeSet attrs) { if (attrs != null) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.pi_PhoneInputStyle); int formatInt = typedArray.getInt(R.styleable.pi_PhoneInputStyle_phoneNumberFormat, -1); switch (formatInt) { case 0: phoneNumberFormat = PhoneNumberUtil.PhoneNumberFormat.E164; break; case 1: phoneNumberFormat = PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL; break; case 2: phoneNumberFormat = PhoneNumberUtil.PhoneNumberFormat.NATIONAL; break; case 3: phoneNumberFormat = PhoneNumberUtil.PhoneNumberFormat.RFC3966; break; } countryFromAttrs = typedArray.getString(R.styleable.pi_PhoneInputStyle_countryIso); typedArray.recycle(); } Countries.get( getContext(), new Countries.Callback() { @Override public void onLoaded(Countries loadedCountries) { countries = loadedCountries; phoneNumberUtil = PhoneNumberUtil.getInstance(); onCountriesLoaded(); } }); }