如何拨打紧急电话号码而不接听电话?

时间:2013-12-03 16:00:09

标签: java android

我有一个非常具体的问题。我的应用程序应该实现呼叫紧急号码(911,112等)。但这必须立即执行,而不必按“呼叫”按钮。我试过通过Intent实现这个:

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

最后,我看到只有数字部分放置号码的拨号屏幕。 有谁知道,如何解决这个问题?

2 个答案:

答案 0 :(得分:8)

你做不到。

拨打紧急电话号码需要CALL_PRIVILEGED权限,根据文件说明:

  

不适用于第三方应用程序。

答案 1 :(得分:1)

如果让用户为自己(家庭,妈妈,妻子等)定义紧急电话号码而不是像911,112这样的紧急电话号码,也许它很有用。 因为可以使用以下方法调用其他数字:

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

相关问题