Intent pickContactIntent = new Intent(Intent.ACTION_PICK,Uri.parse("content://contacts"));
pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
I saw the intent above is only allowed to pick the contacts but I need to pick call logs, favorite, contact just like Android OS Contact Book , How should i achieve this ?
Is there any Intent which allows this or do we need to code it ?
Related
I know that if I create an Intent like this:
val contactPickerIntent = Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI)
startActivityForResult(contactPickerIntent, request_code)
I will be able to pick a contact from my Contacts list.
And if i set the intent like this:
val contactPickerIntent = Intent(Intent.ACTION_VIEW, ContactsContract.Contacts.CONTENT_URI)
I will be able to go into the selected contact details (from within the contacts app) but i won't be able to pick anything from it.
The thing is I need to open the contact's details and select one of it's email addresses, in case he has more than one, and pick it.
Is there a way to do that?
You can change your picker from a Contact picker to an Email picker:
Intent contacts = new Intent(Intent.ACTION_PICK, CommonDataKinds.Email.CONTENT_URI); // Note the Email!
startActivityForResult(contacts, PICK_CONTACTS);
See: https://developer.android.com/guide/components/intents-common#Contacts
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'm getting Cursor with RAW_CONTACTS for person in my app.
How can i use this data to start an Intent to communicate with this person via one of selected raw-contacts?
For example, one contacts has several raw-contacts: phone, whatsapp, viber etc. When i click whatsapp raw_contact, app should start WhatsApp to communicate with selected person.
So simple...
Uri uri = Uri.parse("content://com.android.contacts/data/" + rawContactId);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, rawContactMimetype);
The contacts on the android phone come with settings like "Filter Contacts" that lets the user set things like "Show only contacts that have phone numbers" and "Only show contacts that are online", and which sets of contacts to display (eg, phone only, phone and google etc.).
When doing this
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(intent, PICK_CONTACT);
is there any way to get those filters applied to the contacts list? By default it seems to return everything. If you can't, is there some way to access those settings to see what they are, so I can build my own contacts picker list to match how the phone user has set their default? This only needs to work for Android 2 up.
(The ideal option would be a way to invoke the contact picker that lets the user also set the filters from in there.)
I think if you pass a URI to the intent like the one shown here, you should be able to apply your filter. So you'd do something like this:
Intent intent = new Intent(Intent.ACTION_PICK, PhoneLookup.CONTENT_FILTER_URI);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(intent, PICK_CONTACT);
I was able to use ACTION_PICK with People.CONTENT_URI with the following part of code
Uri myPerson = People.CONTENT_URI;
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,myPerson);
startActivityForResult(contactPickerIntent, CONTACT_ACTIVITY_CODE);
With this I was able to launch the native contact book and on selecting a contact it returned th _ID of that contact. Now what I want is to display the next screen of contact book--the page specific to that selected contact. I tried with the following code. but did not work
Uri myPerson = ContentUris.withAppendedId(People.CONTENT_URI, 23);
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,myPerson);
startActivityForResult(contactPickerIntent, CONTACT_ACTIVITY_CODE);
Here if I change Intent.ACTION_PICK to ACTION_VIEW I am able to view the reqd screen. But I want that screen with ability to return my selection(which will be a phone number or email etc).
You need to do this in a two-step processes. First pick the ID, and let that come back to your activity. Then launch a new intent to view that ID.