Li Che
Li Che

Reputation: 737

The special character of telephone number in android

It has a bug when I test contacts. The bug address is PhoneNumberUtils.charToBCD()

The error is java.lang.RuntimeException: invalid char for BCD; that is to say the ; is not handled.

What is the meaning of the special character of telephone number?

Thankful to any idea regarding this.

Upvotes: 0

Views: 205

Answers (2)

Michael
Michael

Reputation: 35341

@SreekeshOkky mentioned "vcard" in his answer, so maybe it is trying to parse a phone number from a vCard.

In a vCard, phone numbers are usually encoded as free-form text, which means they can contain any character.

They can also be encoded as URIs. A phone number URI will contain a semi-colon if the telephone number has an extension. For example:

tel:+1-555-555-5555;ext=5555

Upvotes: 2

Okky
Okky

Reputation: 10466

The exception is thrown due to

 private static int
    charToBCD(char c) {
        if (c >= '0' && c <= '9') {
            return c - '0';
        } else if (c == '*') {
            return 0xa;
        } else if (c == '#') {
            return 0xb;
        } else if (c == PAUSE) {
            return 0xc;
        } else if (c == WILD) {
            return 0xd;
        } else {
            throw new RuntimeException ("invalid char for BCD " + c);
        }
    }

in the PhoneNumberUtils.java - android-vcard So check a; is passed in your function

Upvotes: 1

Related Questions