问题描述
我想使用 Android SDK 拨打紧急号码.
I want to call Emergency number using Android SDK.
我正在使用以下代码拨打号码 (911).此代码适用于除 911(紧急号码)以外的所有号码.当我使用 911 时,它会显示我不想要的拨号器屏幕.有什么程序可以在不打开拨号器的情况下拨打 911,或者我们可以阻止用户在拨号器屏幕中编辑号码吗?
I am using following code to call the number (911). This code works fine for all the numbers except 911 (Emergency Number). When I use 911, then it shows the dialer screen that I don't want. Is there any procedure to call 911 without open the dialer or can we stop the user to edit the number in Dialer screen?
Uri callUri = Uri.parse("tel://911");
Intent callIntent = new Intent(Intent.ACTION_DIAL,callUri);
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_USER_ACTION);
startActivity(callIntent);
推荐答案
提供的代码应该已经可以解决这个问题,但是您需要 CALL_PHONE 和 CALL_PRIVILEGED 权限才能在不显示拨号盘的情况下拨打紧急号码.
The code provided should already work for this, but you need the CALL_PHONE and CALL_PRIVILEGED permission to dial emergency numbers without showing the dial-pad.
Android 参考 - 清单权限 CALL_PRIVILEGED
一旦添加到清单中,您应该能够使用相同的代码使用 ACTION_CALL 代替直接拨号:
Once that is added to the manifest, you should be able to use the same code using the ACTION_CALL instead to direct dial:
Uri callUri = Uri.parse("tel://911");
Intent callIntent = new Intent(Intent.ACTION_CALL,callUri);
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_USER_ACTION);
startActivity(callIntent);
这篇关于在 Android 中拨打 911的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!