01-04-2014 02:42 PM
I have an app that allows users to select a contact - the app then stores the mobile number and compares it to an MessageContact object which is extracted from a Message object (using Message.sender()).
The problem being that the MessageContact object's address function retrieves the number, which includes the international dialling codes. (e.g. in my case for the UK, it would show +447xxxxxxxxx)
When comparing this to the contact's number from the contact list, the local number is displayed (e.g. in my case for the UK, it would show 07xxxxxxxxx).
Obviously I cannot precisely compare +447xxxxxxxxx with 07xxxxxxxxx as they do not match.
I suppose I could take off the first few characters and do a contains instead, but this is not clean and the length of the codes change per region.
Is there a nicer way to do it? I've had a look around and I haven't found any built in libraries which will convert a local number to an international one.
I've also looked at a few KB articles:
But they don't seem to help as they still return the +44.
01-04-2014 11:45 PM
I think you are going to have to clean the number up any way as users can also add all kinds of characters in to a number including spaces, waits, pauses, etc.
So for your code to work it will need to strip out all non-numeric values, retaining the plus, any values after or before the number using a # or preceding any characters. Once cleaned yes you will then need to look for a preceding plus and remove the international code.
01-04-2014 11:49 PM
I would also ask myself why am I reinventing the wheel and storing the numbers in a seperate location when the user has already taken the time to enter the number including any neccessary predial codes, pauses, waits, extensions, etc. neccessary for it work in the contacts app?
01-05-2014 08:58 AM
01-05-2014 08:30 PM
01-06-2014 04:36 AM
01-06-2014 05:21 AM