Is there a way to add a “name” to an ACTION_CALL intent in android?

我与影子孤独终老i 提交于 2019-12-20 07:13:42

问题


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...



来源:https://stackoverflow.com/questions/13311050/is-there-a-way-to-add-a-name-to-an-action-call-intent-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!