如何使用android.intent.action.CALL_PRIVILEGED和android.intent.action.NEW_OUTGOING_CALL?如何使用、android、inten

2023-09-12 10:25:27 作者:路口等你

我无法找到的文档:

android.intent.action.CALL_PRIVILEGED

我看到它是用来例如在csipsimple来处理呼叫。

I saw it is used for example in csipsimple to handle the call.

我想更好地了解如何使用它。例如:有什么关系 android.intent.action.CALL_PRIVILEGED android.intent.action.NEW_OUTGOING_CALL

I would like to better understand how to use it. For example: what's the relationship between android.intent.action.CALL_PRIVILEGED and 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()的结果为空

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

修改

我做了它的工作处理onNewIntent还有的onCreate。该onResume收到意图没有动作(由默认onNewIntent处理程序,我想送)。

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

问题是,检查动作是否CALL_PRIVILEGED我只好硬code中的字符串android.intent.action.CALL_PRIVILEGED因为动作CALL_PRIVILEGED是隐藏的。

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.

我试图注册该活动ACTION_CALL只和它没有工作

I tried to register the activity for ACTION_CALL only and it did not work

推荐答案

意图与行动 android.intent.action.CALL_PRIVILEGED :当您使用以下方式从电话簿打电话叫: 电话书本 - >接触式>龙点击联系号码 - >选择让从下拉菜单中调用。 继code应该是发生在清单:

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:

<activity>
  <intent-filter>
    <action android:name="android.intent.action.CALL_PRIVILEGED" />
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>

有关HTC的一些变化有:

For HTC some changes there:

<activity>
  <intent-filter>
    <action android:name="android.intent.action.CALL_PRIVILEGED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.item/phone" />
    <data android:mimeType="vnd.android.cursor.item/phone_v2" />
    <data android:mimeType="vnd.android.cursor.item/person" />
  </intent-filter>
</activity>

在此code被添加到清单和尝试上述可以得到应用选择器,并通过这种方式来拦截呼叫,并继续已选定的应用程序拨打电话进行通话。

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.

至于 android.intent.action.NEW_OUTGOING_CALL 它BroadcastReceivers使用的,当你想获得通知有关呼出。例如,如果你要来,你应该把下面的鳕鱼的体现:

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:

<receiver android:name=".CallReceiver"> 
  <intent-filter> 
    <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> 
  </intent-filter> 
</receiver>

和创造

public class CallReceiver extends BroadcastReceiver{
    private static final String TAG = "Call_Receiver";

    @Override
    public void onReceive(Context context, Intent intent) {

        Bundle bundle = intent.getExtras();
        //Notification there
        ....
        }
}

使用此你会得到通知,无论何时,只要呼出happend。

Using this will you get notification all times when outgoing call happend.

beеween该项目的主要区别,首先拦截意图,仅次于得到的结果是什么happend。

The main difference beеween this items that first intercept intent and second only get a result that something happend.