I followed the documentation to start the Show or Create Contact activity. Since my app asks the user if they want to add a contact, I don't want the activity asking this as well. Thus I used the EXTRA_FORCE_CREATE flag.
If I do not use this flag, the code below works fine. It asks the user if they want to add the contact, brings up a selection list where they can choose an existing contact or create a new one, and then shows the add contacts UI. Intent intent = new Intent(); intent.setAction(Contacts.Intents.SHOW_OR_CREATE_CONTACT); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.fromParts("tel", "2065551234", null)); intent.putExtra(Contacts.Intents.EXTRA_FORCE_CREATE, true); // <<<<<< this is the problem line intent.putExtra(Contacts.Intents.Insert.NAME, "Cequint"); intent.putExtra(Contacts.Intents.Insert.NOTES, "test"); intent.putExtra(Contacts.Intents.Insert.PHONE_TYPE, Contacts.PhonesColumns.TYPE_WORK); startActivity(intent); Using the EXTRA_FORCE_CREATE flag, the activity does not start and the logcat output shows that the intent forwarded by the ShowOrCreateActivity fails: 06-11 19:00:33.198: INFO/ActivityManager(583): Starting activity: Intent { action=com.android.contacts.action.SHOW_OR_CREATE_CONTACT categories={android.intent.category.DEFAULT} data=tel:2065551234 comp= {com.android.contacts/com.android.contacts.ShowOrCreateActivity} (has extras) } 06-11 19:00:33.369: INFO/ActivityManager(583): Starting activity: Intent { action=android.intent.action.INSERT type=vnd.android.cursor.dir/person comp={com.android.contacts/ com.android.contacts.EditContactActivity} (has extras) } 06-11 19:00:33.459: DEBUG/UserLaunch:(992): onRestart() 06-11 19:00:33.479: DEBUG/UserLaunch:(992): onStart() 06-11 19:00:33.709: ERROR/EditContactActivity(862): Cannot resolve intent: Intent { action=android.intent.action.INSERT type=vnd.android.cursor.dir/person comp={com.android.contacts/ com.android.contacts.EditContactActivity} (has extras) } Looking at the Contacts Manifest, I found that sending this Intent would take me directly to the add contacts UI, but will always create a new contact even if there is already one for that number: Intent intent = new Intent(Intent.ACTION_INSERT, People.CONTENT_URI); intent.putExtra(Contacts.Intents.Insert.PHONE, "2065551234"); intent.putExtra(Contacts.Intents.Insert.NAME, "Cequint"); intent.putExtra(Contacts.Intents.Insert.NOTES, "test"); intent.putExtra(Contacts.Intents.Insert.PHONE_TYPE, Contacts.PhonesColumns.TYPE_WORK); startActivity(intent); Am I doing something wrong with the first example? Or is there a bug in the Contacts app? This is with SDK 1.5 r2. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---