Android 如何 截獲撥號

來源:互聯網
上載者:User

使用者在系統的撥號應用中輸入完號碼並且按撥號鍵後,還沒真正撥出去前,我想作一些操作。比如修改號碼或者檢查許可權。

       覺得系統的撥號動作應該還是發送一個intent,理論上是可以截獲的。 終於,在開源工程sipUA中看到了方法。如下:

       首先,仔細看看API中關於intent.ACTION_NEW_OUTGOING_CALL的描述。寫得很多很詳細,節選一部分“You must hold the PROCESS_OUTGOING_CALLS permission to receive this Intent.This is a protected intent that can only be sent by the system”。

       系統撥號動作其實就是發送了一個包含這樣一個intent的Broadcast Action。我們可以寫個receiver來獲得此intent. 如sipUA中:

java代碼:

<receiver android:name=".ui.Caller">         <intent-filter android:priority="-1">         
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />         </intent-filter>     </receiver>

       需要注意的是 android:priority=”-1″  為什麼截獲這個intent需要這樣設定,可以參考API中的說明。當然還要注意加上

java代碼:

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>

原文出外: http://www.eoeandroid.com/thread-100615-1-1.html

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.