I'm having a problem specifically with HTC Sense's Phone Dialer removing any letters from a phone number passed to it. I'm using this code to start the Phone intent and it works on Stock Android. I don't have a Samsung with TouchWiz to test with so it's possible that this is also a problem there.
public void callPhoneNumber(Context context, String number) {
...
//Number will be something like "123-456-TEST"
number = "tel:" + number;
context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(number)));
...
}
On stock Android if I have a number like "123-456-TEST", it will be interpreted correctly as "123-456-8378" whereas with HTC Sense it will end up with "123-456" in the dialer. If they are all numbers both work just fine. Is there anyway besides writing my own phone number parser to pass the number correctly to the HTC intent? Thanks in advance.
Basically I just added my own parsing before I add it to the Intent. I just use this really sloppy regex to get the job done. If anyone has a simpler regex to accomplish this I'd appreciate it.
public void callPhoneNumber(Context context, String number) {
...
number = "tel:" + replaceLettersInNumber(number);
context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(number)));
...
}
public static String replaceLettersInNumber(String number) {
return number
.replaceAll("[ABCabc]", "2")
.replaceAll("[DEFdef]", "3")
.replaceAll("[GHIghi]", "4")
.replaceAll("[JKLjkl]", "5")
.replaceAll("[MNOmno]", "6")
.replaceAll("[PQRSpqrs]", "7")
.replaceAll("[TUVtuv]", "8")
.replaceAll("[WXYZwxyz]", "9");
}