Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 =  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?

like image 204
Flow Avatar asked Jun 24 '11 21:06

Flow


People also ask

How do I find the default phone number on Android?

What is this? Launch the Phone app > select the Contacts tab at the bottom right. Tap on the desired contact > Tap the “i” icon to open the contact details. Select the number you wish to set as default.

What does it mean to set a phone number as default?

The default phone number is used when you initiate a call or send a text message using the Context menu that opens when you touch and hold the contact's entry.

How do I change the default number in Contacts?

Open up the Google Contacts app on Android. Go to the desired contact (do not edit the contact). Long press the phone number you want to set as the default number.

How do I select a contact primary number on iPhone?

If you want to specify which number should be called when tapping a contact, then open the Contacts App, tap on the contact, then tap and hold on the "Call" button at the top of the contact, and select the number to call from the list. It will set that number as the default option for Calls for that specific Contact.


1 Answers

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

like image 189
Kenny Avatar answered Nov 26 '22 11:11

Kenny