@ -9,41 +9,75 @@ 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).
# Want to report an issue?
If you want to report an issue, or to contribute to the project, please read
the guidelines [here](CONTRIBUTING.md) first.
# Quick links
* Reporting an issue? Want to send a pull request? See the [contribution
guidelines](CONTRIBUTING.md)
* Check the [frequently asked questions](FAQ.md)
* Fun! [Falsehoods Programmers Believe About Phone Numbers](FALSEHOODS.md)
* Look for
[`README`s](http://github.com/googlei18n/libphonenumber/find/master) in
directories relevant to the code you're interested in.
* For contributors and porters: [How to run the Java demo](run-java-demo.md)
* For porters: [How to make metadata changes](making-metadata-changes.md)
# Highlights of functionality
* Parsing/formatting/validating phone numbers for all countries/regions of the world.
* ` getNumberType ` - gets the type of the number based on the number itself; able to distinguish Fixed-line, Mobile, Toll-free, Premium Rate, Shared Cost, VoIP and Personal Numbers (whenever feasible).
* ` isNumberMatch ` - gets a confidence level on whether two numbers could be the same.
* ` getExampleNumber `/` getExampleNumberByType ` - provides valid example numbers for all countries/regions, with the option of specifying which type of example phone number is needed.
* ` isPossibleNumber ` - quickly guessing whether a number is a possible phonenumber by using only the length information, much faster than a full validation.
* ` isValidNumber ` - full validation of a phone number for a region using length and prefix information.
* ` AsYouTypeFormatter ` - formats phone numbers on-the-fly when users enter each digit.
* ` findNumbers ` - finds numbers in text input.
* ` PhoneNumberOfflineGeocoder ` - provides geographical information related to a phone number.
* ` PhoneNumberToCarrierMapper ` - provides carrier information related to a phone number.
* ` PhoneNumberToTimeZonesMapper ` - provides timezone information related to a phone number.
@ -82,7 +116,9 @@ http://groups.google.com/forum/#!forum/libphonenumber-discuss) for every
release.
# Quick Examples
Let's say you have a string representing a phone number from Switzerland. This is how you parse/normalize it into a ` PhoneNumber ` object:
Let's say you have a string representing a phone number from Switzerland. This
is how you parse/normalize it into a `PhoneNumber` object:
```java
String swissNumberStr = "044 668 18 00";
@ -94,7 +130,8 @@ try {
}
```
At this point, swissNumberProto contains:
At this point, `swissNumberProto` contains:
```json
{
"country_code": 41,
@ -102,14 +139,19 @@ At this point, swissNumberProto contains:
}
```
` PhoneNumber ` is a class that is auto-generated from the phonenumber.proto with necessary modifications for efficiency. For details on the meaning of each field, refer to https://github.com/googlei18n/libphonenumber/blob/master/resources/phonenumber.proto
`PhoneNumber` is a class that was originally auto-generated from
`phonenumber.proto` with necessary modifications for efficiency. For details on
the meaning of each field, refer to `resources/phonenumber.proto`.
More examples on how to use the library can be found in the unittests at https://github.com/googlei18n/libphonenumber/tree/master/java/libphonenumber/test/com/google/i18n/phonenumbers
More examples on how to use the library can be found in the [unit