質問

I'm working on adding contact picker functionality to app, as well as the ability to add a contact from the app into the native contact manager. For inserting, I'm launching the contact manager like so:

Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION);

intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.PHONE, mCurrentNumber);
intent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, "MyType");

mActivity.startActivityForResult(intent, ADD_CONTACT);

This successfully opens the contact manager and populates it with the phone number as specified. However, on my Nexus 7 tablet when the contact manager returns it goes back to the main screen and does not send any sort of response to my app. This works fine and returns as expected on my ICS device, but I don't know if that's because the ICS device is using a custom contact manager from the manufacturer while the Nexus 7 is Google's.

Can anyone shed some light on this issue? Is there a problem with the way I launch the contact manager?

EDIT: I should also add that if I select "Discard" from the Contact Manager options menu on the Nexus 7, it does return to my app as expected. It's only if I select the "Done" button that the problem occurs. Selecting "Done" navigates to the main menu of the Contact Manager at which point any attempts to exit the Contact Manager will take the user to the home screen.

役に立ちましたか?

解決

Turns out the fix for this was to add

intent.putExtra("finishActivityOnSaveCompleted", true);

to the contact intent. This bypassed the details view of the contact manager and returned control to my app, with the proper call to onActivityResult.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top