Goal is to have something as similar to LibPhonenumber to format phone number based on country code
Android 4.0 or higher
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.mammahe:Format-Number-Libphonenumber:0.1.0'
}
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).
Copyright 2019 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.