开发者

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

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

String where =  Con开发者_Go百科tactsContract.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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜