Formatting of number from contacts

好久不见. 提交于 2019-12-11 03:16:35

问题


I'm writing some sms application for android and i have a problem. I send sms from one emulator to another. That sms has "15555215556" as phone number it was sent from. When i save that number to contacts, it's saved in "+1-555-521-5556" format. Next, when my app search phone book to find matching phone number, it couldn't find any, because "15555215556" is not the same as "+1-555-521-5556" (in phone book).

Is there any built-in class that can properly format given phone number?


回答1:


There is the phone number util class

http://developer.android.com/reference/android/telephony/PhoneNumberUtils.html

otherwise you can use libphoneumber

http://code.google.com/p/libphonenumber/

only 140 KB



来源:https://stackoverflow.com/questions/6003504/formatting-of-number-from-contacts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!