'Android PhoneNumberUtils.formatNumberToE164 India Numbers
I have to validate mobile and phone numbers based on the user's default device country if the user has not entered the international country code. So I was testing for India mobile numbers and I found that irrespective of the user has entered country code or not, PhoneNumberUtils.formatNumberToE164 will always return null for mobile numbers starting from 6, 7, 8. It will only format and validate if the number starts from 9. The code i use is below. So is this some kind of bug or m i doing something wrong
String formatedNumber = PhoneNumberUtils.formatNumberToE164("6xxxxxxxxx","IN")
Note: For sharing purpose i have passed static "IN" else i have a method to get the country dynamically using telephone manager and also i have added xx in number for masking, i have tried with a valid mobile number with 6 series, 7 series, and 8 series.
I m aware of google/libphonenumber but that library is very heavy and i do not require that much functionality.
I m afraid, that for India I can do a check of different mobile number series but when the app will be live and used in different countries, I m not aware of the consequences of this issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|