1

I have a very specific problem. My app should implement calling emergency numbers (911, 112, etc.). But this must perform immediately, without pressing "Call" button. I've tried implement this via Intent:

Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:" + getString(R.string.emd_emergency_number)));
startActivity(intent);

Finally, I see only dialer screen with number placed in number section. Does anybody know, how to resolve this problem?

  • 3
    You can't for emergency numbers. http://stackoverflow.com/questions/1811680/dial-number-without-prompt – NigelK Dec 03 '13 at 16:02

2 Answers2

8

You can't do that.

Calling emergency numbers require CALL_PRIVILEGED permission which, according to the documentation is :

Not for use by third-party applications.

njzk2
  • 38,969
  • 7
  • 69
  • 107
  • I've alredy applied such permissions as: ' ', but it doesn'twork. – user3062157 Dec 03 '13 at 16:07
  • 1
    but the documentation states that this permission cannot be granted to third-party application. – njzk2 Dec 03 '13 at 16:08
  • So, @njzk2, I cannot dial the emergency number through my app without accepting ? – user3062157 Dec 03 '13 at 16:10
  • you can only dial, not make the actual call. you can also refer to the documentation for ACTION_CALL : `this Intent cannot be used to call emergency numbers. Applications can dial emergency numbers using ACTION_DIAL, however.` – njzk2 Dec 03 '13 at 16:11
1

Maybe it is usefull if let the user define a emergency number for himself(home,mum,wife,etc) instead of emergency number like 911,112. Because other numbers can be called with:

public static final String ACTION_CALL 
Activity Action: Perform a call to someone specified by the data.

Input: If nothing, an empty dialer is started; else getData() is URI of a phone number    to be dialed or a tel: URI of an explicit phone number.

Output: nothing.

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.
Constant Value: "android.intent.action.CALL"

http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL

Jaran
  • 212
  • 2
  • 10