Call 911 in Android(在 Android 中拨打 911)
问题描述
我想使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Android 中拨打 911


基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01