如何使用 android.intent.action.CALL_PRIVILEGED 和 android.intent.action.NEW_OUTGOING_CALL?
我找不到以下文档:
android.intent.action.CALL_PRIVILEGED
我看到它在 csipsimple 中用于处理呼叫。
我想更好地了解如何使用它。例如:之间有什么关系 android.intent.action.CALL_PRIVILEGED
和 android.intent.action.NEW_OUTGOING_CALL
?
我
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
在我的项目的 AndroidManifest 中 添加了:当从本机拨号器启动呼叫时,我的活动被调用,但如果在 onResume 中执行 getIntent().getAction() ,结果为 null
编辑
我让它可以处理 onNewIntent 以及onCreate。 onResume 接收一个没有操作的意图(我想是由默认的 onNewIntent 处理程序发送的)。
问题是,要检查该操作是否为 CALL_PRIVILEGED,我必须对字符串“android.intent.action.CALL_PRIVILEGED”进行硬编码,因为操作 CALL_PRIVILEGED 是隐藏的。
我尝试仅注册 ACTION_CALL 的活动,但没有成功
I can't find the documentation for:
android.intent.action.CALL_PRIVILEGED
I saw it is used for example in csipsimple to handle the call.
I would like to better understand how to use it. For example: what's the relationship betweenandroid.intent.action.CALL_PRIVILEGED
and android.intent.action.NEW_OUTGOING_CALL
?
I added:
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
in the AndroidManifest for my project. When a call is start from the native dialer, my activity is called but if in the onResume I do getIntent().getAction() the result is null
EDIT
I made it working handling the onNewIntent as well as onCreate. The onResume receives an intent without an action (sent by the default onNewIntent handler I suppose).
The problem is that to check whether the action is CALL_PRIVILEGED I had to hard-code the string "android.intent.action.CALL_PRIVILEGED" because the action CALL_PRIVILEGED is hidden.
I tried to register the activity for ACTION_CALL only and it did not work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您使用以下方式从电话簿拨打电话时,会调用带有操作android.intent.action.CALL_PRIVILEGED的意图:
电话本->联系人->长按电话号码->从下拉菜单中选择拨打电话。
以下代码应放置在清单中:
对于 HTC 进行一些更改:
当将此代码添加到清单中并且您尝试按照上述方式进行呼叫时,您可以获得应用程序选择器,这样可以拦截呼叫并继续通过所选应用程序进行呼叫。
至于android.intent.action.NEW_OUTGOING_CALL,它在BroadcastReceivers中使用,当你想获得有关拨出电话的通知时。例如,如果您想要这样做,您应该将以下代码放入 Manifest:
并创建:
使用此功能,您将在发生拨出呼叫时始终收到通知。
这些项目之间的主要区别是,第一个拦截意图,第二个仅得到发生某事的结果。
Intent with action android.intent.action.CALL_PRIVILEGED is called when you making a call from phonebook using following way:
Phone Book->Contact->Long Click on the phonenumber -> Choose make call from dropdown menu.
Following code should be place in Manifest:
For HTC some changes there:
When this code is added to Manifest and you try to make call as described above you can get Application Chooser and this way to intercept the call and continue making call by the choosen application.
As for android.intent.action.NEW_OUTGOING_CALL it used in BroadcastReceivers, when you want to get notification about outgoing call. For example if you want to to that you should put following cod to Manifest:
and create:
Using this will you get notification all times when outgoing call happend.
The main difference beеween this items that first intercept intent and second only get a result that something happend.
你不能使用这个意图。它具有特殊的保护级别,仅允许选定的应用程序发布它。更多信息请参见:http://code.google.com/p/android /issues/detail?id=10344 该意图和许多其他意图不适用于第三方应用程序,但您可以通过其他方式利用它们。
例如,您可以抓住它们。但如果您不小心,这将意味着默认的 Android Dialer 应用程序无法启动任何呼叫,因为大多数应用程序都使用此意图。如果你捕获了它,你可以将它作为一个简单的 ACTION_CALL 意图转发,这样就可以了。
You cannot use that intent. It has a special protection level that allows only select applications to issue it. More info here: http://code.google.com/p/android/issues/detail?id=10344 That intent and many others are not available to third party apps, but you can harness them in other ways.
For example, you can catch them. But if you are not careful, this will mean that no calls can be started with the default Android Dialer application as most of those use this intent. If you catch it, you can forward it as a simple ACTION_CALL intent, that will work.
Nikolay Nikiforchuk 的回答中已经说明了这一点,但可能没有明确强调,区别在于,如果您仅处理 CALL_PRIVILEGED,您的应用程序将被列为启动呼叫的选项。因此,在开始调用之前,框架将询问用户应使用哪个应用程序来执行该操作。
如果您仅处理 NEW_OUTGOING_CALL,框架将使用标准拨号器,但拨打的号码将传递到您的应用程序广播接收器,该接收器将有机会挂断呼叫并处理它或修改电话号码,然后将其传递给其他注册的接收者。
It is already stated in Nikolay Nikiforchuk's answer but maybe not explicitly underlined that the difference is that if you handle only CALL_PRIVILEGED your application will be listed as an option to start the call. So before starting the call the framework will ask the user which application should be used to perform the operation.
If you handle only NEW_OUTGOING_CALL the framework will use the standard dialler but the dialled number will be passed to your application broadcast receiver that will have a chance to drop the call and handle it or to modify the phone number and than pass it through the other registered receiver.