I would like to launch an app the user selects from within my application. However, I\'m not sure how I\'d go about doing this. I\'ve tried this:
Intent inte
You need to pass extra information into the intent to tell Android what you want to show or create. Otherwise Android doesn't know what activity to start and (presumably in your case) throws an ActivityNotFoundException
.
For a contact, you use the generic Intent.ACTION_INSERT_OR_EDIT
then use the MIME type of an individual contact (Contacts.People.CONTENT_ITEM_TYPE
).
For example:
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
intent.setType(People.CONTENT_ITEM_TYPE);
intent.putExtra(Contacts.Intents.Insert.PHONE, "+1234567890");
intent.putExtra(Contacts.Intents.Insert.PHONE_TYPE, Contacts.PhonesColumns.TYPE_MOBILE);
That will bring up the contacts app, prompting you to select an existing contact to add the phone number to, or to create a new contact.
You don't need to add anything special to your manifest to start external activities. Only if you were to directly manipulate the contacts ContentProvider
would you need to add the appropriate CONTACT permissions to your manifest.