Search code examples
androidandroid-intentactionandroid-dialer

Android Intent ACTION_CALL not making a phone call


In my Android application I would like to make a phone call automatically when user click the button. I have used the below set of code to achieve this functionality

Intent intent = new Intent(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:911"));
                startActivity(intent);

and in my AndroidManifest.xml I have added this <uses-permission android:name="android.permission.CALL_PHONE" /> permission too.

But it is just opening the dialer pad with the given 911 no instead of making a phone call.


Solution

  • At least in the US, 911 is an emergency number. CALL_PHONE is insufficient to call that number. There is a separate permission for that (CALL_PRIVILEGED?), one that cannot be held by ordinary SDK apps.

    UPDATE: I remembered correctly. Here is the Android 6.0 platform manifest entry for that permission:

    <!-- @SystemApi 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.
             <p>Not for use by third-party applications. -->
        <permission android:name="android.permission.CALL_PRIVILEGED"
            android:protectionLevel="signature|privileged" />