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
基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
