开发者

How do I remove the "+" and country code from a phone number?

开发者 https://www.devze.com 2023-04-13 01:55 出处:网络
I am using following API to get a phone number; however, some of the device will return the number in following format:

I am using following API to get a phone number; however, some of the device will return the number in following format:

"+" + countrycode + phone number Ex. +12062436969

TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String phoneNumber = tm.getLine1Number();

I would like to find out a way/algorithm to remove this "+" sign and the coun开发者_开发问答try code, so I will get only the last ten digits. Ex. +12062436969 -> 2062436969

I believe I only need the last ten digits. could anyone please suggest any idea?


You should definitely have a look at this amazing library :

http://code.google.com/p/libphonenumber/
https://github.com/googlei18n/libphonenumber

This will solve your problem and might even help you more since you are doing telephony stuff.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号