Overview
PhoneNumberType is an enum that represents different types of phone numbers. Use this to categorize phone numbers and understand their characteristics.
Getting the Type
Get the type of a phone number usingPhoneNumberUtil::getNumberType():
Phone Number Types
The following types are available in thePhoneNumberType enum:
| Type | Value | Description |
|---|---|---|
| FIXED_LINE | 0 | Traditional landline numbers |
| MOBILE | 1 | Mobile/cellular numbers |
| FIXED_LINE_OR_MOBILE | 2 | Numbers that could be either fixed-line or mobile. In some regions (e.g., USA), it’s impossible to distinguish between these types. |
| TOLL_FREE | 3 | Freephone lines (e.g., 800, 888 numbers in the US) |
| PREMIUM_RATE | 4 | Premium rate numbers that charge higher rates |
| SHARED_COST | 5 | Numbers where the call cost is shared between caller and recipient (typically less than premium rate) |
| VOIP | 6 | Voice over IP numbers, including TSoIP (Telephony Service over IP) |
| PERSONAL_NUMBER | 7 | Personal numbers associated with a person, may route to mobile or fixed-line |
| PAGER | 8 | Pager numbers |
| UAN | 9 | Universal Access Numbers or Company Numbers (one number for entire company) |
| UNKNOWN | 10 | Numbers that don’t fit any known pattern for the region |
| EMERGENCY | 27 | Emergency service numbers (e.g., 911, 999) |
| VOICEMAIL | 28 | Voicemail access numbers |
| SHORT_CODE | 29 | Short codes (typically 4-6 digits) |
| STANDARD_RATE | 30 | Standard rate numbers |
Usage Examples
Basic Type Checking
Filtering by Type
Handling Different Types
Business Logic Based on Type
Regional Differences
Type Characteristics
Common Use Cases by Type
FIXED_LINE- Business landlines
- Residential phones
- May not support SMS
- Cell phones
- Supports SMS and calls
- May have different rate plans
- Customer service lines
- Free for caller to dial
- Business uses (800, 888, 877, etc.)
- Pay-per-call services
- Entertainment lines
- Higher charges apply
- Internet-based phone services
- May have different routing
- Often used by businesses
- Single number for organizations
- Routes to multiple locations
- Common for large companies
See Also
- PhoneNumberUtil - Use
getNumberType()to determine type - PhoneNumber - The phone number object being categorized
- Validation - Validate numbers before checking type