I have an application that i have created in Java using Libgdx that among other things sends text messages via the users default SMS manager.
I pull contacts into the app from the users own contact list and I now need a method that will check to see if the number pulled in is a valid number. At the moment, working out of the UK, i check to see if:
-the string (as phone numbers are brought in as strings) is equals to 11 characters, if so check the first two numbers and compare them to "01" all the way to "09" and if so replace the 0 with +44 e.g. 07999999999 will become +447999999999. This gives me a valid number that i can use.
-or if the string begins with +44, i check if the string is 13 characters long and if so it is a valid number.
-if not remove the number from the list.
Now, this works perfectly for numbers in Great Britain as +44 is the country code for GB. However when i start to branch out i will need a way to handle all kinds of different numbers of different lengths (i would assume), so what im looking for is an approach where i can generalise, as much as possible, so that my code is as streamlined as possible.
I know how to get the default Locale of the phone so i can determine where the app is being used and from my limited understanding i would guess that is the basis on which this approach should come from but im not quite sure how to continue.
Any information on the subject will be greatly appreciated,