When i try to use this Intent like so....
Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT);
i.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
startActivityForResult(i,INSERT_CONTACT);
it loads the contact list then after selecting or creating a contact I do not return back to my app. i have checked the logs and nothing stands out. Is there a new intent action in ICS?
Thanks
Your missing this line:
intent.putExtra(ContactsContract.Intents.Insert.NAME, "Larry Page");
Valid "fields":
http://developer.android.com/reference/android/provider/ContactsContract.Intents.Insert.html
Related
I have a raw contact ID for a contact in my application. I want to open the native contact phonebook for editing in my contact (basically the contact in edit mode in native address book). How can I do that?
What I understand from your question is that, you have a contact id you want to open that in android native address book against that id. If that is the case then below code should help you
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf("18"));
intent.setData(uri);
startActivity(intent);
In String.valueOf() method provide the contact id you want to open.
Problem resolved.
I did this with below code
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setData(ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, contactID));
startActivity(intent);
I have got following project requirment.
When user has given android.permission.WRITE_CONTACTSpermission in his manifest then we should add contact programatically. ( This part is done and working perfectly).
Now the challenge is If user has not given this permission then i will not able to add contact programatically but the best effort i want to put is show him prefilled contact screen and let him press add button.
I got this working on Android 2.0 and up.But I am facing issue to make it work on android 1.6 device.
Below is the code which works on Android 2.0 and up.
Intent i = new Intent(ContactsContract.Intents.Insert.ACTION,
ContactsContract.Contacts.CONTENT_URI);
i.putExtra(ContactsContract.Intents.Insert.NAME, "Vipul Shah");
i.putExtra(ContactsContract.Intents.Insert.PHONE, "1234");
startActivity(i);
Any help will be highly appreciated.
Thanks
This is because ContactsContract is only present in API5+ (Android 2.0) environments.
The relevant class in pre-API5 is called Contacts
if (android.os.Build.VERSION.SDK_INT > 5)
Intent i = new Intent(ContactsContract.Intents.Insert.ACTION,
ContactsContract.Contacts.CONTENT_URI);
i.putExtra(ContactsContract.Intents.Insert.NAME, "Vipul Shah");
i.putExtra(ContactsContract.Intents.Insert.PHONE, "1234");
startActivity(i);
} else {
Intent i = new Intent(Contacts.Intents.Insert.ACTION,
People.CONTENT_URI);
i.putExtra(Contacts.Intents.Insert.NAME, "Vipul Shah");
i.putExtra(Contacts.Intents.Insert.PHONE, "1234");
startActivity(i);
}
i want to open the contact intent with a name already in the search box. can id do that?
if so how?
no i'm calling to the intent like that:
Intent pickContactIntent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);
pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(pickContactIntent, SELECT_PERSON_REQUEST_CODE);
help any one?
thank you from ahead!
Currently this feature doesn't exists.
I need to allow user to select some audiofile from his media library.
Here's what I'm trying to do:
Intent tmpIntent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
);
startActivityForResult(tmpIntent, 0);
But I get error:
08-20 17:44:35.444: E/AndroidRuntime(3773): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.PICK dat=content://media/external/audio/media }
To be on the safe side, I also tried INTERNAL_CONTENT_URI, but result is similar.
How can I achieve this?
UPD: by the way, if I try to pass URI to get images (i.e. android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), then it works: image open dialog is opened.
UPD2: Just tried this on emulator - my code works! But on two devices it doesn't (SE Xperia Neo and some Acer). But if I try the second variant from this answer, then I got menu with all my existing file-managers, and with "Music select" too! But I need to write Intent just to open this "Music select".
Well, I have seen in LogCat what happens when I open music select dialog, and I got what I need. This code works for me:
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
startActivityForResult(tmpIntent, 0);
If I want to get, say, notifications sounds only, then I need to put extra, just like that:
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
startActivityForResult(tmpIntent, 0);
I'm trying to open the 'Add Contact' screen via an intent, and I want it with the names already set (first name and family name).
For that, I'm trying to do this:
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.NAME, "My Name");
intent.putExtra(ContactsContract.Intents.Insert.PHONETIC_NAME, "Family Name");
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "12345"));
activity.startActivityForResult(intent, 2);
In this case, the second field in the 'Add Contact' screen keeps empty, and a new field appears with the string "Family Name", that's because I've set the PHONETIC_NAME.
What I want to know is, how do I add the family name value to the second field in 'Add Contact' screen?
I've searched for this question but it doesn't solve. It uses some kind of vCards. I don't know anything about it, if this is the right way to implement this, can someone help me understand how to implement it?
Try this:
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.NAME, "FirstName MiddleName LastName");
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "12345");
startActivityForResult(intent, 2);
;) Goodluck