Created
June 1, 2014 19:07
-
-
Save nguyenvanduocit/567e9ed9fb216cc66632 to your computer and use it in GitHub Desktop.
Launch the 'Add Contact'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add listener so your activity gets called back upon completion of action, | |
// in this case with ability to get handle to newly added contact | |
myActivity.addActivityListener(someActivityListener); | |
Intent intent = new Intent(Intent.ACTION_INSERT); | |
intent.setType(ContactsContract.Contacts.CONTENT_TYPE); | |
// Just two examples of information you can send to pre-fill out data for the | |
// user. See android.provider.ContactsContract.Intents.Insert for the complete | |
// list. | |
intent.putExtra(ContactsContract.Intents.Insert.NAME, "some Contact Name"); | |
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "some Phone Number"); | |
// Send with it a unique request code, so when you get called back, you can | |
// check to make sure it is from the intent you launched (ideally should be | |
// some public static final so receiver can check against it) | |
int PICK_CONTACT = 100; | |
myActivity.startActivityForResult(intent, PICK_CONTACT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment