I can pick multi contact data via
Intent phonebookIntent = new Intent("intent.action.INTERACTION_TOPMENU");
phonebookIntent.putExtra("additional", "phone-multi");
phonebookIntent.putExtra("maxRecipientCount", MAX_PICK_CONTACT);
phonebookIntent.putExtra("FromMMS", true);
startActivityForResult(phonebookIntent, REQUEST_CODE_PICK_CONTACT);
but when I want to add another contact to present data , the selected contact data disappears.Is there an intent filter like "selectedList" by which I can send id list to contact picker intent
That could be impossible to do using implicit intent. You can always create your own activity, get the contacts using ContentProvider, pass the parameters you want and handle the logic there.
Related
I see in a app a contactpicker Intent that show for a contact that have multiple phone number like this:
--------------------
Friend 1
Mobile 555567777777
--------------------
Friend 2
Mobile 555567777777
Work cc555567777777
Home 44564646
--------------------
I can't find a way to do this only to retrieve one contact and query phone numbers after.
How I can call the intent to do in this way?
You could do something like this:
Intent intent = new Intent();
intent.setClassName("com.android.contacts","com.android.contacts.activities.PeopleActivity");
startActivity(intent);
Based on "Modifying Contacts Using Intents" (Android developer documentation) and the answer to "Start add new contact activity and pass structured data", I've devised a way of populating the Android contact picker with data to be edited and saved by the user.
I also have a comparable "headless" method using ContentProviderOperation, which works as intended for all contact fields I've tried (name, phone number, e-mail, structured address etc.).
However, when using the intent, somehow the structured address gets discarded and does not appear in the contact picker. A website URL added with the same method works fine.
This is my code, somewhat condensed:
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
ArrayList<ContentValues> data = new ArrayList<ContentValues>();
ContentValues addressRow = new ContentValues();
addressRow.put(Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE);
// The string values are prepared earlier, and I check that none of them is null.
// The ContentProviderOperation way doesn't seem to mind nulls, however.
addressRow.put(ContactsContract.CommonDataKinds.StructuredPostal.STREET, street);
addressRow.put(ContactsContract.CommonDataKinds.StructuredPostal.POBOX, pobox);
addressRow.put(ContactsContract.CommonDataKinds.StructuredPostal.NEIGHBORHOOD, neighborhood);
addressRow.put(ContactsContract.CommonDataKinds.StructuredPostal.CITY, city);
addressRow.put(ContactsContract.CommonDataKinds.StructuredPostal.REGION, region);
addressRow.put(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE, postcode);
addressRow.put(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY, country);
addressRow.put(ContactsContract.CommonDataKinds.StructuredPostal.TYPE, addressType);
data.add(addressRow);
// This website address is shown in the contact edit screen, as expected:
ContentValues urlRow = new ContentValues();
urlRow.put(Data.MIMETYPE, ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE);
urlRow.put(ContactsContract.CommonDataKinds.Website.URL, urlValue);
data.add(urlRow);
intent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, data);
startActivityForResult(intent, ADD_CONTACT_REQUEST); // my own request code
Please note that using an intent and using a ContentProviderOperation are different ways of achieving the same thing, both appropriate for their respective scenarios. My question is about the intent, so the answers to the following SO questions were not too helpful:
"Not able to insert address of contacts in android"
"How to add structured data to a new contact Intent"
Any suggestions as to what I'm messing up here?
I'd like to send arbitrary strings (not paths or URLs) between two of my company's Android apps, but the Intent data is a URI. Presently I'm concerned with starting an Activity, but in some cases it would be nice to be able to send a query and receive a response without starting an Activity. So:
How should I send any arbitrary string when Intent wants a URI?
What other communication mechanisms could I use?
For Intent intent = new Intent();, you can use intent.putExtra(String name, String value); to store a String value that is keyed to name. In your called activity, use intent.getStringExtra(name); to retrieve the value.
You can add an arbitrary string to an intent by using extras on the intent.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra(SOME_STATIC_NAME_VALUE, "your_arbitrary_string");
There are many options for extra's, see http://developer.android.com/reference/android/content/Intent.html
To retrieve the string in your receiving activity, use
intent.getExtras().getString(SOME_STATIC_NAME_VALUE)
Or the appropriate getter for whatever value you set on the extra.
In my application i want to add the contact number . So here i called the Below code . It call the Add contact screen but i want to set the contact number using code . can any one help me to solve my problem ?
Intent intent = new Intent(Intent.ACTION_INSERT,People.CONTENT_URI);
startActivityForResult(intent, 1);
It is called Add Contact Screen .
As far as I know INSERT creates an empty contact. Maybe you can create an entry and then call the action.EDIT pointing to he new contact
Here is the Solution.
Intent addContactIntent = new Intent(Contacts.Intents.Insert.ACTION, Contacts.People.CONTENT_URI);
addContactIntent.putExtra(Contacts.Intents.Insert.PHONE,"Phone Number");
startActivity(addContactIntent);
I need to update a contact name but i didn't way the way to do that with the old contact api (my application must work in 1.5,1.6 AND 2.X)
Ahan well do something like this
Intent i = new Intent(Intent.ACTION_EDIT);
i.setData(Uri.parse("content://com.android.contacts/raw_contacts/1));
//Here 1 is the id of the contact to edit. You can also generate it automatically.
startActivity(i);
If you mean at runtime you want to select id from an text box , you can do something like
Intent i = new Intent(Intent.ACTION_EDIT);
i.setData(Uri.parse("content://com.android.contacts/raw_contacts/" + textBox.getText() ));
//Here textBox should have any numerical value of the contact to edit.
startActivity(i);