Use following code to open Add contact screen.
in On activityResult we will get added contact URI .
Intent i = new Intent(Intent.ACTION_INSERT); i.setType(ContactsContract.Contacts.CONTENT_TYPE); if (Integer.valueOf(Build.VERSION.SDK_INT) > 14) i.putExtra("finishActivityOnSaveCompleted", true); // Fix for 4.0.3 + startActivityForResult(i, ADD_CONTACT_REQUEST);
in On activityResult we will get added contact URI .
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ADD_CONTACT_REQUEST) { if (resultCode == RESULT_OK) { Log.i("contact ", "Added successfully"); Log.i("data", data.toString() + ", uri : " + data.getData().toString()); } else { Log.i("contact ", "contact add cancelled "); } } }
No comments :
Post a Comment