Search code examples
androidandroid-intentphone-call

How to Make a Call directly in Android


I know it was very simple to do it but I come across a very strange issue. I have to call Police in danger Situation by just tapping a button. So I have used following code to call.

Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("tel:100"));
            callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            ctx.startActivity(callIntent);

Added CALL_PHONE permission in AndroidManifest.xml. The Issue is that it is opening the 100 on Dial Pad but not making call directly. I want that to happen immediately when user clicks on the button.

When I tried to to put +91 before 100 it is calling the number automatically but why plus is required for such numbers. So Someone help me how to solve this issue


Solution

  • From the documentation of ACTION_CALL:

    Note: there will be restrictions on which applications can initiate a call; most applications should use the ACTION_DIAL.

    Note: this Intent cannot be used to call emergency numbers. Applications can dial emergency numbers using ACTION_DIAL, however.

    So it seems this behavior is on purpose.