Horrorgoogle
Horrorgoogle

Reputation: 7868

How to call phone number with respective name in android

Trying to call number with name.It is possible to make name with number calling.

I successfully calling following code:

 Intent callIntentp2 = new Intent(Intent.ACTION_CALL);
 callIntentp2.setData(Uri.parse("tel: 55555555");
 startActivity(callIntentp2);

It's Output looks like

55555555 Dialing

But I want to call with name just like you saved on contact list on your sim.but i have data in manually not from sim.

John 55555555 Dialing

Is that possible.

Upvotes: 2

Views: 729

Answers (1)

zgc7009
zgc7009

Reputation: 3389

ACTION_CALL is a native Android intent. When you call it, Android performs background processes that bring up the default call view. There are ways you could chop together some broadcast receiver to overlay an activity on top of the native call screen, but you are asking for trouble on that end. Without a rooted device, this is a difficult process. This question is actually very similar to:

Replace native outgoing call Screen by custom screen android

I haven't read through the link or anything, but I am pretty sure they are going to say the same thing. Without doing some weird, iffy work-around you aren't likely to achieve this.

You could (theoretically) take the time prior to calling to add the number with the attached name to your contacts list. When the call is made, it will show the name and the number (since the name is listed as a contact and that is Android's default action). Once the call is done you could delete the contact so that it doesn't get stuck in a persons contact list that doesn't want it.

A bit of code for example:

ContentValues contactValues = new ContentValues();
        contactValues.put(Data.RAW_CONTACT_ID, 001);
        contactValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
        contactValues.put(Phone.NUMBER, "555-555-5555");
        contactValues.put(Phone.TYPE, Phone.TYPE_CUSTOM);
        contactValues.put(Phone.LABEL, "John");
        Uri dataUri = getContentResolver().insert(
             android.provider.ContactsContract.Data.CONTENT_URI, contactValues);

Don't forget to add write contact permission to your applications manifest. Again, this is just an option (the only one I can really think of off the top of my head)

Upvotes: 2

Related Questions