在 Android 中拨打 911
我想使用 Android SDK 拨打紧急号码。
我正在使用以下代码拨打号码(911)。此代码适用于除 911(紧急号码)之外的所有号码。当我使用 911 时,它会显示我不想要的拨号屏幕。是否有任何程序可以在不打开拨号器的情况下拨打 911,或者我们可以阻止用户在拨号器屏幕中编辑号码吗?
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);
I want to call Emergency number using Android SDK.
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
提供的代码应该已经可以实现此目的,但您需要 CALL_PHONE 和 CALL_PRIVILEGED 权限才能拨打紧急号码而不显示拨号盘。
Android 参考 - 清单权限 CALL_PRIVILEGED
将其添加到清单后,您应该能够使用相同的代码使用 ACTION_CALL 代替直接拨号:
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 Reference - Manifest Permission CALL_PRIVILEGED
Once that is added to the manifest, you should be able to use the same code using the ACTION_CALL instead to direct dial:
Action_Dial将打开拨号盘,Action_Call将直接调用..
但是,引用 ACTION_CALL:
Action_Dial will open the dialpad, Action_Call will call directly..
However, a quote from ACTION_CALL:
假设将
Intent.ACTION_CALL
替换为Intent.ACTION_DIAL
,这将呼叫号码,而不会在拨号盘上显示该号码。Say
Intent.ACTION_CALL
insted ofIntent.ACTION_DIAL
this will call number without showing it on dial pad.en el oncreate uso los 绑定
en el oncreate uso los bindings