How to show the name of the person instead of phone numbers? - android

Intent myIntent = new Intent(Intent.ACTION_DIAL);
myIntent.setData(Uri.parse("tel:" +CallNumber));
startActivity(myIntent);
Is there any possibilities to show the contact name instead of the phone numbers on selecting menuitem call?

Maybe this link on stackoverflow can help:
Get Contact by Phone number on Android
First use it to retrieve the contact name based on the phone number. Then use:
myIntent.setData(Uri.parse("content://contacts/people/"+PersonName))
to call the person.

Related

Showing name along with number when making phone call from custom contact list app in android

I made a simple contact list app where user can save name and mobile number of person.User can also call the saved number by using this app.My problem is when making call number is shown,But name is not shown.
Can anyone know,How can I show the name along with the number when making call to someone from my custom contact list app???
here is my few part of my code
c.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(Showdetail1.this, "call button clicked :"+contact.get_mobile(),
Toast.LENGTH_LONG).show();
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+contact.get_mobile()));
//change the number
//callIntent.putExtra("com.android.phone.extra.slot", 0); //For sim 1
startActivity(callIntent);
}
});
Phone is not showing the name because that number doesn't exists in your contact list. For showing the name instead of number while calling you need to store the number in contact using method shown in this post
https://stackoverflow.com/a/4744514/3758972
when contact is saved successfully whenever you call, it will show contact name.

Calling a Contact picker that show multiple numbers of user contact

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);

Set Contact Number in Contact Uri

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);

insert contact intent, multiple phone / email / etc types?

android allows me to launch an intent to create a new contact. i can put extras into the intent to pre-fill the new contact fields.
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.NAME, "Foo Bar");
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "(408) 555-1212");
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, "foo.bar#foobar.com");
startActivityForResult(intent, INSERT_CONTACT_REQUEST);
this works, but i don't see how to handle multiple types of a given field, say phone number. in the intent, i can put extra a phone number, and i can put extra a phone number type, but how do i put extra an additional phone number, with a different (or perhaps even the same) type?
ContactsContract.Intents.Insert allows for PHONE, SECONDARY_PHONE and TERTIARY_PHONE - the same applies for EMAIL and it suggests three of each might be the maximum.
I don't know if it's possible to have more than one phone of the same 'type' - my phones contacts editor removes 'Home' from the list of choices once I've assigned a home number for example. You can, however, assign your own 'custom' type. For example, suppose your friend has two home numbers...
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "(123) 456-1212");
intent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, "HOME-1");
intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE, "(123) 456-2121");
intent.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, "HOME-2");

android update contact name

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);

Categories

Resources