Intention for contacts with a phone number

Please, is it possible to select from contacts only with phone numbers using the default application for intentions and contacts?

Perhaps some modification of this (shows a selection from all contacts):

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, CONTACT_PICKER_ID);
+5
source share
2 answers
Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(intent, 1);
+7
source

You can open the cursor on contacts and launch through contacts with phone numbers. You could recreate the activity of selecting contacts, which is shown with the intention that you spoke about using this cursor (dropping them into the list to select)

        ContentResolver cr = getContentResolver();
        Cursor phoneCur = cr.query( 
                ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
                null,
                null, 
                null, 
                null); 
        while (phoneCur.moveToNext()) { 
            String phone = phoneCur.getString(
                      phoneCur.getColumnIndex(
                              ContactsContract.CommonDataKinds.Phone.DATA));
            //do something, check if empty...
        } 
        phoneCur.close();

with this approach, you will also need permission to read the contact in your manifest

<uses-permission android:name="android.permission.READ_CONTACTS"/>
+3
source

All Articles