Is there a way to open the contact details window (I mean the window/activity which is shown, if I select one, from the contacts list) per intent with the phone number ?
Thanks!
By using ContactsContract we open contact page
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI,
String.valueOf(contactID));
intent.setData(uri);
context.startActivity(intent);
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'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);
I'm trying to find out whether a particular contact is a whatsapp user or not.
This goes my requirement:
I have a text to share and also have a phone number of a person as well. The priority of my sharing goes as follows
If the phone number is already present in CONTACTS and :
if the contact is a whatsapp user, I should call sharing intent of SEND with package set as "com.whatsapp"
i.e:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.setPackage("com.whatsapp");
intent.putExtra(Intent.EXTRA_TEXT, message);
startActivity(intent);
if the contact not a whatsapp user, I should call intent for default messaging app.
i.e :
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + phoneNumber ) );
intent.putExtra( "sms_body", message );
startActivity(intent);
If the phone number is not present, create a contact and do as above.
My question now is, how do I find out whether my contact is a whatsapp user or not? Is whatsapp providing any API to find out that?
Thanks in advance
PS: I do not want to show a general sharing intent which shows a list of sharing apps. I may do that only if the device does not have whatsapp application at all.
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 ?
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.