google libphonenumber get only mobile numbers from contacts

时光毁灭记忆、已成空白 提交于 2019-12-13 02:26:07

问题


I'm using libphonenumber to format phonenumbers in contacts. Is there any way to display only mobile numbers like WhatsApp? no local phone numbers.

The only idea I have is to have a list with all mobile area codes like https://en.wikipedia.org/wiki/List_of_mobile_phone_number_series_by_country and check every number but this is a bit complicated I think.


回答1:


found the answer...

PhoneNumberUtil.PhoneNumberType nrtype = phoneUtil.getNumberType(NumberProto);
if (nrtype.name() == PhoneNumberUtil.PhoneNumberType.MOBILE) {
}



回答2:


Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, personId);

Uri phonesUri = Uri.withAppendedPath(personUri, People.Phones.CONTENT_DIRECTORY);
String[] proj = new String[] {Phones._ID, Phones.TYPE, Phones.NUMBER, Phones.LABEL}

Cursor cursor = contentResolver.query(phonesUri, proj, null, null, null);


来源:https://stackoverflow.com/questions/31760665/google-libphonenumber-get-only-mobile-numbers-from-contacts

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