问题
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