簡體   English   中英

如何在不接聽電話的情況下撥打緊急電話?

[英]How to call emergency number without accepting call?

我有一個非常具體的問題。 我的應用程序應實現緊急呼叫電話(911、112等)。 但這必須立即執行,而無需按“呼叫”按鈕。 我試過通過Intent實現此:

Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:" + getString(R.string.emd_emergency_number)));
startActivity(intent);

最后,我只能看到在數字部分放置了數字的撥號程序屏幕。 有人知道如何解決這個問題嗎?

你不能那樣做。

撥打緊急電話需要CALL_PRIVILEGED許可,根據文檔所述,該許可為:

不適用於第三方應用程序。

如果讓用戶為自己(家,媽媽,妻子等)定義一個緊急電話號碼,而不是像911,112這樣的緊急電話號碼,則可能很有用。 因為可以用以下方式調用其他號碼:

public static final String ACTION_CALL 
Activity Action: Perform a call to someone specified by the data.

Input: If nothing, an empty dialer is started; else getData() is URI of a phone number    to be dialed or a tel: URI of an explicit phone number.

Output: nothing.

Note: there will be restrictions on which applications can initiate a call; most           applications should use the ACTION_DIAL.

Note: this Intent cannot be used to call emergency numbers. Applications can dial       emergency numbers using ACTION_DIAL, however.
Constant Value: "android.intent.action.CALL"

http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM