user73554
user73554

Reputation: 103

PhoneNumberUtils.isGlobalPhoneNumber not working correctly

I passed '55' to isGlobalPhoneNumber, and it returns 'true'.

I want it only return true for US phone numbers xxx-xxx-xxxxx.

Upvotes: 0

Views: 2145

Answers (1)

dst
dst

Reputation: 3337

55 is a valid phone number according to the definition Android provides in its source code (as context-free grammar):

global-phone-number = ["+"] 1*( DIGIT / written-sep )
written-sep         = ("-"/".")

Whether or nor this definition is suitable for your application is, of course, independent of that definition.

Upvotes: 3

Related Questions