1

I have developed one code to edit contact but it is not working in the android 4.0 and above. Activity of edit is starting but closes immediately and backs to the parent activity.Do not know what is the problem, here is my code:

Intent i = new Intent(Intent.ACTION_EDIT);
i.setData(Uri.parse(ContactsContract.Contacts.CONTENT_LOOKUP_URI
                                                + "/" + contactId[position]));
int REQUEST_CODE = 2;
startActivityForResult(i, REQUEST_CODE);

Any solution will be appreciated.

Rushabh Patel
  • 3,052
  • 4
  • 26
  • 58

1 Answers1

1

After researching and made one solution of the above problem is as below:

Intent i = new Intent(Intent.ACTION_EDIT);
i.setData(Uri.parse(ContactsContract.Contacts.CONTENT_URI
                                            + "/" + contactId[position]));
int REQUEST_CODE = 2;
startActivityForResult(i, REQUEST_CODE);

you just need to use content_uri instead of content_lookup_uri.

Rushabh Patel
  • 3,052
  • 4
  • 26
  • 58
  • 1
    which uri you use depends on the type of index you pass in. If you pass in a LOOKUP_KEY, I think you need to use CONTENT_LOOKUP_URI. I presume you were passing in a row id, not a lookup key. – Peri Hartman Feb 22 '13 at 20:43
  • @Rushabh when i start contact edit screen and make some edit and press done it is not send me to my app instead it sedn to native contact detail screen .And when i press back button it show me contact list then again press back button send me to my app.Any idea to solved this issue. – Herry Mar 22 '13 at 08:07