I have created an intent as follows:
I am trying to use the contacts db to store new contacts I create in my app. But I am having a tough time with invocation of
protected void onActivityResult(int requestCode, int resultCode, Intent data)
...Does not get called
Step 1: Created intent in Activity 1
Intent insertIntent = new Intent(ContactsContract.Intents.Insert.ACTION);
insertIntent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
// Sets the special extended data for navigation
insertIntent.putExtra(ContactsContract.Intents.Insert.NAME, name);
if (Integer.valueOf(Build.VERSION.SDK_INT) > 14) {
insertIntent.putExtra("finishActivityOnSaveCompleted", true);
}
/*
* * Demonstrates adding data rows as an array list associated with the DATA key
* */
// Defines an array list to contain the ContentValues objects for each row
ArrayList<ContentValues> contactData = new ArrayList<ContentValues>();
/*
* * Defines the raw contact row
* */
// Sets up the row as a ContentValues object
ContentValues rawContactRow = new ContentValues();
// Adds the account type and name to the row
rawContactRow.put(ContactsContract.RawContacts.ACCOUNT_TYPE, "com.mydomain.com");
rawContactRow.put(ContactsContract.RawContacts.ACCOUNT_NAME, contactName);
// Adds the row to the array
contactData.add(rawContactRow);
/*
* * * Adds the array to the intent's extras.
* */
insertIntent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, contactData);
if (isHoneycomb()) {
insertIntent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, parcels);
}
CALL STARTACTIVITYFOR RESULT
static final int INSERT_CONTACT_REQUEST = 2;
startActivityForResult(insertIntent, INSERT_CONTACT_REQUEST);
Step 2 Called startActivityforResult() from Activity1. The app now creates the contact which I confirmed, but after completing it doesn't seem to call this method below defined in Activity1.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.i ("onActivityResult", "enter the routine!");
// Check which request we're responding to
System.out.println("result requestCode" + INSERT_CONTACT_REQUEST);
Uri contactUriTry = data.getData();
String contactUriString = contactUriTry.toString();
System.out.print(contactUriString);
I don't have noHistory=true etc...
Any pointers where I could be going wrong?