Reputation: 11177
In my app I'm trying to format the phone number typed in an EditText
. For that I'm using a PhoneNumberFormattingTextWatcher.
I'm having issues with this class. Trying to use the constructor PhoneNumberFormattingTextWatcher(String countryCode)
doesn't compile. I can't find it in the documentation but it's definitely in the sdk (see the code source).
What's wrong with that class?
Upvotes: 1
Views: 5135
Reputation: 116030
According to the documentation, this CTOR is available from API21 , so you can either copy the code for pre-Lollipop, or use it when you can:
Upvotes: 0
Reputation: 8702
I highly suggest you to use PhoneNumberUtils
to format a phone number.
https://developer.android.com/reference/android/telephony/PhoneNumberUtils.html
And especially these two methods:
formatNumber(String source)
Breaks the given number down and formats it according to the rules for the country the number is from.formatNumber(Editable text, int defaultFormattingType)
Formats a phone number in-place.Upvotes: 0
Reputation: 5790
The PhoneNumberFormattingTextWatcher(String countryCode)
is hidden API, as you can see from the @hide
tag in the javadoc. In other words: that particular constructor is not part of the SDK.
Upvotes: 5