Jun 11, 2018 Replies: 2 At Erel's suggestion I have relocated this library to here - see this thread for how it came to be: https://www.b4x.com/android/forum/threads/libphonenumber.63361 This library is a super simple wrap of google's libphonenumber library. The only functionality exposed is to validate a phone number. Usage: Code: Copy Private Sub Process_Globals Private Obj_phonevalidator As PhoneValidator End Sub Private Sub FOO_sub(phoneno As String) Private good_no as Boolean = Obj_phonevalidator.Validate(phoneno, "AU") End Sub AU is the default country code - always uppercase, AU = Australia, US = ... If you specify a default country code then you can test phone nos using the nomenclature internal to that country. If you set default country code to "" then all phone nos to be tested must be in E.164 format (https://en.wikipedia.org/wiki/E.164) otherwise result will be false. You must also install libphonenumber-8.9.7.jar (as at writing - the latest and greatest) to your B4A additional libraries folder, I got it from: https://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber/8.9.7 EDIT: You should regularly update the libphonenumber-x.x.x.jar for reasons alluded to by Sandman at: https://www.b4x.com/android/forum/threads/validate-phone-number.107798/#post-674235 At 21 July 2019 this stands at 8.10.15: https://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber/8.10.15 You also need to edit the ...B4A/Additional Libraries/phonevalidator.xml to reflect this update. Enjoy... Attachments phonevalidator.zip phonevalidator.zip 1.6 KB · Views: 535 Last edited: Jul 21, 2019 Click to expand...
At Erel's suggestion I have relocated this library to here - see this thread for how it came to be: https://www.b4x.com/android/forum/threads/libphonenumber.63361 This library is a super simple wrap of google's libphonenumber library. The only functionality exposed is to validate a phone number. Usage: Code: Copy Private Sub Process_Globals Private Obj_phonevalidator As PhoneValidator End Sub Private Sub FOO_sub(phoneno As String) Private good_no as Boolean = Obj_phonevalidator.Validate(phoneno, "AU") End Sub AU is the default country code - always uppercase, AU = Australia, US = ... If you specify a default country code then you can test phone nos using the nomenclature internal to that country. If you set default country code to "" then all phone nos to be tested must be in E.164 format (https://en.wikipedia.org/wiki/E.164) otherwise result will be false. You must also install libphonenumber-8.9.7.jar (as at writing - the latest and greatest) to your B4A additional libraries folder, I got it from: https://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber/8.9.7 EDIT: You should regularly update the libphonenumber-x.x.x.jar for reasons alluded to by Sandman at: https://www.b4x.com/android/forum/threads/validate-phone-number.107798/#post-674235 At 21 July 2019 this stands at 8.10.15: https://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber/8.10.15 You also need to edit the ...B4A/Additional Libraries/phonevalidator.xml to reflect this update. Enjoy...
JackKirk Well-Known Member Licensed User Longtime User Oct 9, 2018 #3 A note - I have just successfully run this library in B4J. Just copy the .jar and .xml from the zip in post #1 to your B4J additional libraries folder. Also copy the libphonenumber-8.9.7.jar to your B4J additional libraries folder. Tick the phonevalidator library in your B4J Library Manager, cobble together a bit of code similar to post #1 and bang - it works!!!
A note - I have just successfully run this library in B4J. Just copy the .jar and .xml from the zip in post #1 to your B4J additional libraries folder. Also copy the libphonenumber-8.9.7.jar to your B4J additional libraries folder. Tick the phonevalidator library in your B4J Library Manager, cobble together a bit of code similar to post #1 and bang - it works!!!