我如何删除&QUOT + QUOT;和一个电话号码国家code? [英] How do I remove the "+" and country code from a phone number?
问题描述
我使用下列API来获取一个电话号码;然而,一些设备将在下面的格式返回数:
I am using following API to get a phone number; however, some of the device will return the number in following format:
++国家code +电话号码前。 12062436969
"+" + countrycode + phone number Ex. +12062436969
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String phoneNumber = tm.getLine1Number();
我想找出路/算法,以消除这个+号和国家code,所以我将只得到最后的十位数。防爆。 12062436969 - > 2062436969
I would like to find out a way/algorithm to remove this "+" sign and the country 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://$c$c.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.
这篇关于我如何删除&QUOT + QUOT;和一个电话号码国家code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!