Questions tagged [libphonenumber]

Google's common Java, C++ and Javascript library for parsing, formatting, storing and validating international phone numbers. The Java version is optimized for running on smartphones, and is used by the Android framework since 4.0 (Ice Cream Sandwich).

libphonenumber is a library for handling phone numbers. It can parse and format phone numbers as well as provide geographical information about phone numbers.

libphonenumber is written by Google engineers and is used in Android and other Google projects.

230 questions
9
votes
1 answer

Is it possible to programatically distinguish between American and Canadian phone numbers?

I'm using this bit of code (in Groovy, but it should be pretty clear what it does) class MobileNumberUtilService { def getISOCountryCode(rawNumber) { def phoneNumberUtil = PhoneNumberUtil.getInstance() def number try { number =…
Okal Otieno
  • 345
  • 4
  • 13
8
votes
1 answer

Use google-libphonenumber in angular reactive forms validator

This is a basic use case for using this library. I need to verify the number if it is valid. I use angular reactive forms custom validators. Validator is in file: validators/phone-number.validator.ts First step is to get google-libphonenumber…
8
votes
2 answers

icu4j is too big, any alternative?

I am using icu4j in my android code. The jar is about 10MB, which causes my entire application to register an apk of 15MB. Of course the 15MB is likely due to Proguard helping reducing the size. Anyway, does anyone know of a smaller alternative to…
Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
7
votes
3 answers

Extract country code from phone number in flutter

I have phone number as String like "+91 96001 64500", (Getting the data from google places API) I want to extract the phone number(without country code) as well as country code, without knowing the country (Country can be any country). How can I do…
L Uttama
  • 379
  • 1
  • 4
  • 14
6
votes
1 answer

Missing Meta data in com.googlecode.libphonenumber:libphonenumber:8.8.2 while building signed APK

I added com.googlecode.libphonenumber:libphonenumber:8.8.2 in my project. In debug mode its works normally.But in signed apk its generating the following exception when a library method is called. Caused by: java.lang.IllegalStateException: missing…
Ashikee AbHi
  • 385
  • 2
  • 12
6
votes
1 answer

Android Facebook Account Kit Crash - missing metadata: /com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CN

I am suddenly getting a number of crash reports around this the past few weeks. The crashes indicated missing metadata for certain country code. Most of them have been one…
6
votes
2 answers

Use libphonenumber to validate mobile phone number without knowing the country

I have a list (string) of phone numbers from any country. for example: var items = new List { "+989302794433", "009891234599882", "+391234567890", "00336615551212"}; at first, I think that every country code length is exactly two number,…
KoKo
  • 421
  • 1
  • 5
  • 21
6
votes
2 answers

import com.google.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder class not found

Probably missing something dumb, I'm guessing I need to add some code. But I added the following jar file to my project. The user enters a phone number and I'm able to retrieve the country phone code, but I want to retrieve the country name as well…
Diego
  • 4,011
  • 10
  • 50
  • 76
6
votes
2 answers

Get E 164 format of contacts in Android API less than 16

I retrieve the list of contact numbers from the phone using the following code: Cursor c = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); while(c.moveToNext()){ Log.d(TAG,"NO.: "+…
geekoraul
  • 2,623
  • 2
  • 21
  • 33
5
votes
0 answers

Generating fake phone numbers that are valid based on libphonenumber's rules

I'd like to use libphonenumber to validate phone numbers, but a number of our integration tests are using Faker to generate test data, and the numbers that this generates are not always valid based on the full validation rules defined in…
Andrew Skirrow
  • 3,402
  • 18
  • 41
5
votes
3 answers

How to match phone number prefix to country from phonenumber in SQL

I am trying to extract the country code prefix from a list of numbers, and match them to the region that they belong to. The data might look something like this: | id | phone_number | |----|----------------| | 1 | +27000000000 | | 2 |…
user3623641
  • 319
  • 1
  • 3
  • 10
5
votes
3 answers

Is it possible to check whether a given phone number is of a cell phone or not?

Background It is possible to check if a given string represents a valid phone number, using this code, together with the PhoneNumberUtil library by Google (available here) : public static boolean isValidNumber(final PhoneNumber phone) { if…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
5
votes
1 answer

Using Google's libphonenumber library for validation international mobile number without region

I'm trying to validate an international mobile number. For example: "+972523254545". Afaik, this number should be valid everywhere. But this library requires "region" too. why is that and how can I overcome it?
Hagai L
  • 1,593
  • 1
  • 18
  • 40
5
votes
3 answers

Why doesn't python phonenumbers library work in this case?

It seems like '5187621769' should be a very easy number for the phonenumbers library to parse. It's 10 digits with a US area code. But...no luck. Setup: import phonenumbers number = '5187621769' Method 1: parsed = phonenumbers.parse(number) This…
exp1orer
  • 11,481
  • 7
  • 38
  • 51
5
votes
2 answers

How to format phone number realtime (when using UITextfield) in iOS for different region codes?

I found 'NBAsYouTypeFormatter' and referred to the demo provided. But, I want phone number formatted dynamically when user entering phone number in UITextField. Remember, region code is not fixed to one or two country in my case e.g. only @"US" or…
NSPratik
  • 4,714
  • 7
  • 51
  • 81
1
2
3
15 16