简体   繁体   中英

How to call emergency number without accepting call?

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM