0

I my app a user can create or choose like this:

Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
                intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
                intent.putExtra(ContactsContract.Intents.Insert.NAME,
                        user.getName());
                intent.putExtra(INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED,
                        true);
                startActivityForResult(intent, ADD_CONTACT);

Then in onActivityResult:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {
            Log.e(TAG, "DATA NULL");
            return;
        }
        if (requestCode == ADD_CONTACT) {
            if (resultCode == RESULT_OK) {
                //QUESTION HERE
                Uri contactData = data.getData();
                Cursor c = getContentResolver().query(contactData, null, null,
                        null, null);

            } else {
                Log.e(TAG, "RESULT NOT OK!");
            }
        }
    }

Question: Is there any way to decide, if user created or chose an existing contact ? :)

Matej Špilár
  • 2,617
  • 3
  • 15
  • 28

2 Answers2

1

You can get the number of contacts before user action and after it (with this: how many contacts in contact list). Than just compare.

Community
  • 1
  • 1
amukhachov
  • 5,822
  • 1
  • 41
  • 60
0

You can keep count of the contacts in case you dont need the information regarding the change/added contact.

In case you need what has changed/added you can check for this answer for observer

Hope this helps

Community
  • 1
  • 1
Swati
  • 1,179
  • 9
  • 28