Is there a way to add a “name” to an ACTION_CALL i

2019-03-03 12:57发布

问题:

Here's a code snippet of what I have:

 call_phone = new Intent(Intent.ACTION_CALL);
 call_phone.setData(Uri.parse(parameter)); // parameter is a phone number tel:someNumber
 con.startActivity(call_phone);

Since the phone number is not listed in my actual contacts - I just wanted to know if there was a way to pass a putExtra or a setName or something along those lines - that would let me make the dialer display any name I want to call - along with the number?

I have looked around on stack overflow and on the android developer website - but can't find anything specific like setting the name, setting the number is all over the place.

回答1:

Sorry if this answer isn't helpful but:

It's the Phone application which catches the "ACTION_CALL" intent Action. Since this is a device specific app it may vary.

Having a quick google I can't find any information either on what extra's it accepts but I would imagine that injecting a "name" could be considered a security vulnerability and therefore wouldn't be part of the app (however I'm not sure).

Giving your app permissions and functionality to add a contact however (and therefore associating a name with a number) is entirely possible and there are many examples out there on how to interface with the Contacts ContentProvider.



回答2:

Since the android specification is not mentioning a name parameter on this intent I'd discouarge using it. DOC HERE

Documentation also mentions that most apps should ACTION_DIAL, as ACTION_CALL might have some restrictions on which apps can call it...