Skip to content

Releases: mammahe/Format-Number-Libphonenumber

Phone number format using LibPhonenumber

24 Jul 17:18
Compare
Choose a tag to compare

Goal is to have something as similar to LibPhonenumber to format phone number based on country code

Requirements

Android 4.0 or higher 

Usage

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

dependencies {
	        implementation 'com.github.mammahe:Format-Number-Libphonenumber:Tag'
	}

Step 3. Add import in activity

import com.sairamkrishna.formatnumber.FormatNumber;

Step 4. Example usage in activity

hyphen.setText("Hyphen: "+FormatNumber.getFormattedNumber("+919652018244","Hyphen",this));
national.setText("National: "+FormatNumber.getFormattedNumber("+919652018244","National",this));
international.setText("International: "+FormatNumber.getFormattedNumber("+919652018244","International",this));
e164.setText("E164: "+FormatNumber.getFormattedNumber("+919652018244","E164",this));

Step 5. Detail information about usage

FormatNumber.getFormattedNumber("+919652018244","Hyphen",this);

getFormattedNumber required three strings as 

1. Phone number included country code as +1.

2. Which format needed to get out put. There are four formats are available as HYPHEN, NATIONAL,INTERNATIONAL, E164. 

3. Context of an activity (default string is this).

Output

License

Copyright 2015 Sairamkrishna Mammahe

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software under the License is distributed on an "AS IS" BASIS, WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. the License for the specific language governing permissions and under the License.