Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 878
Jamal Avatar asked May 06 '16 13:05

Jamal


People also ask

How do you call implicit intent?

Implicit Intent with URI data Uri number = Uri. parse("tel:11061991"); Intent callIntent = new Intent(Intent. ACTION_DIAL, number);

What is Android intent Action view?

An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view a map" or "take a picture") in an Intent object.


1 Answers

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" />
like image 53
CommonsWare Avatar answered Oct 15 '22 10:10

CommonsWare