3

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

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
kingston
  • 11,053
  • 14
  • 62
  • 116
  • http://stackoverflow.com/questions/2296905/which-activity-handles-intent-action-call-privileged possibly you may find this answer helpful – Wojciech Owczarczyk Nov 25 '11 at 11:57
  • The documentation in here http://developer.android.com/reference/android/Manifest.permission.html says about CALL_PRIVILEGED "Allows an application to call any phone number, including emergency numbers, without going through the Dialer user interface for the user to confirm the call being placed." What other info are you looking for? – Alexander Kulyakhtin Nov 25 '11 at 14:46
  • But that is about the permission and not the action right? I was looking for something about the action – kingston Nov 25 '11 at 16:20
  • So now my solution is working but the question is still open: is there a documentation of that action? Is there a way to do the same using an action that is documented? – kingston Nov 26 '11 at 14:53
  • Just a note: you do not need the CALL_PRIVILEGED permission to catch the CALL_PRIVILEGED action – kingston Jun 26 '13 at 12:13

3 Answers3

11

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>

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>

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:

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

and create:

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

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.

Nikolay Nikiforchuk
  • 1,998
  • 24
  • 20
  • 1
    I set it as accepted answer although it does not answer the pending question but only the first one (before my edit). The question is still: is that Intent documented? Is it portable to use it? Is there a more portable way to do the same? – kingston Dec 12 '11 at 13:28
4

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.

allprog
  • 16,540
  • 9
  • 56
  • 97
3

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.

  • Seems CALL_PRIVILEGED no more supporting. I tested for S8(OS 7.0) & One+(6.0) device. But it always launch native dealer app only. – CoDe Oct 30 '17 at 14:08