3

The title seems to be a duplicate of this.

However as I tried the solution and reading further came to know that CALL_PRIVILEGED permission is only possible for system apps. Hence I wanted to know if there's any work-around to this.

What I want to achieve is quite obvious, call an emergency number such as 911 directly without opening the dialer screen. (which I found is not possible for security reasons. Still trying.)

My Assumption: (The following steps are stupid assumptions of mine to achieve the above)

A. Use Action_DIAL intent action and open the dialer screen with 911 already dialed into it by doing this,

 Intent callIntent = new Intent(Intent.ACTION_DIAL);
 callIntent.setData(Uri.parse("tel:" + "911"));
 startActivity(callIntent);

Here my dream code starts. If only these are possible.

B. Register a receiver which will check if the dialer is open (looking for an Intent if exists for this) and the number it contains is 911.

C. Call the click event of the CALL button programmatically. (Again if this is possible)

Please tell me if above is possible? I am also trying to get this done. Also any other way to achieve this would be great.

EDIT - I am hoping if this can be possible without user having the root access.

Community
  • 1
  • 1
Atul O Holic
  • 6,692
  • 4
  • 39
  • 74
  • Out of interest, why are you trying to call 911 automatically? You can get into serious trouble for calling emergency numbers with out proper reason. – IAmGroot May 21 '14 at 10:58
  • I am working on an emergency app and need to call this directly without much user interaction. – Atul O Holic May 21 '14 at 10:59

2 Answers2

1

Add these two permission in Manifest file.

public static final String CALL_PHONE

Added in API level 1 Allows an application to initiate a phone call without going through the Dialer user interface for the user to confirm the call being placed. Constant Value: "android.permission.CALL_PHONE"

public static final String CALL_PRIVILEGED

Added in API level 1 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. Not for use by third-party applications. Constant Value: "android.permission.CALL_PRIVILEGED"

After adding to the manifest, you may able to make call using ACTION_CALL

Uri uri = Uri.parse("tel://911");
Intent intent = new Intent(Intent.ACTION_CALL,uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_USER_ACTION);
startActivity(intent);

Update: But you can use this feature if your app will be installed on the system partition (e.g., by a rooted device user) or signed with the same signing key that signed the rest of the firmware (e.g., by a device manufacturer or ROM modder).

Reference

Mukesh Kumar Singh
  • 4,512
  • 2
  • 22
  • 30
1

You have 2 options here

  1. Using an Intent When you use an 'Intent.ACTION_DIAL' to dial a call that you have done here, then you must understand that you always end up relaying the default dialer of the application because your asking the OS that we need a listener to this intent so you end up opening an application. so using this method this cant be done

  2. Make a custom dialer
    The only work around that I can find is that you make your own custom dialer but for that you need to make a custom ROM.

Considering your requirement I would have to say that it is not possible

Now considering what you have provided as a solution

Call the click event of the CALL button programmatically

Due to the sandbox restrictions and security reasons I really doubt the possibility.

Girish Nair
  • 5,148
  • 5
  • 40
  • 61