問題描述
我想使用 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!