我使用下列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.