How to detect the default phone number of a contact (if set)

放肆的年华 提交于 2019-12-19 07:32:51

问题


ATM I get the number and label of a given CONTACT_ID with

String where =  ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId;
Cursor c = ctx.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, where, null, null);
     while (c.moveToNext()) {
     String number = Tools.getString(c, CommonDataKinds.Phone.NUMBER);
     String label = Tools.getString(c,CommonDataKinds.Phone.LABEL);
     }

Android has the ability to mark a given number as "default number". How can I find out if the queried number is the default number?


回答1:


Try to query for the column IS_SUPER_PRIMARY in your CONTENT_URI query.

If it returns a non-zero value then the entry may be interpreted as the default contact value of its kind (for example, the default phone number to use for the contact).

More info: http://developer.android.com/reference/android/provider/ContactsContract.Data.html



来源:https://stackoverflow.com/questions/6474019/how-to-detect-the-default-phone-number-of-a-contact-if-set

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