我正在使用 libphonenumber 来格式化联系人中的电话号码。有没有办法只显示像 WhatsApp 这样的手机号码?没有本地电话号码。
我唯一的想法是列出所有移动区号,例如https://en.wikipedia.org/wiki/List_of_mobile_phone_number_series_by_country并检查每个号码,但我认为这有点复杂。
我正在使用 libphonenumber 来格式化联系人中的电话号码。有没有办法只显示像 WhatsApp 这样的手机号码?没有本地电话号码。
我唯一的想法是列出所有移动区号,例如https://en.wikipedia.org/wiki/List_of_mobile_phone_number_series_by_country并检查每个号码,但我认为这有点复杂。
找到了答案...
PhoneNumberUtil.PhoneNumberType nrtype = phoneUtil.getNumberType(NumberProto);
if (nrtype.name() == PhoneNumberUtil.PhoneNumberType.MOBILE) {
}
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);