I'm trying to open contacts and let user decide if he/she want to create or select a contact to use it on my app.
I need something like this:
Where on the first option the user can add a new contact.
I tried the following code:
Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT);
i.setType(ContactsContract.Contacts.CONTENT_TYPE);
i.putExtra("finishActivityOnSaveCompleted", true); // Fix for 4.0.3 +
startActivityForResult(i, CARREGA_CONTATOS);
But a got this error on Logcat (right after startActivityForResult):
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT_OR_EDIT typ=vnd.android.cursor.dir/contact (has extras) }
What I'm doing wrong?
EDIT:
I tried this code also with similar result:
Intent intent = new Intent(
Intent.ACTION_INSERT_OR_EDIT,
ContactsContract.Contacts.CONTENT_URI
);
startActivityForResult(intent, CARREGA_CONTATOS);
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT_OR_EDIT dat=content://com.android.contacts/contacts }
EDIT 2: Almost what I need:
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
i.putExtra("finishActivityOnSaveCompleted", true); // Fix for 4.0.3 +
startActivityForResult(i, CARREGA_CONTATOS);
But this code opens this image, and the user must select "Contacts" before it goes to where I want.