在我的應用程序,有一個特點,結束呼出(並開始其他活動),同時撥打某個號碼(例如*123*
)Android - 如何立即結束與telephonyService的呼叫?
它目前的工作,但需要200毫秒的延遲。沒有延遲,意圖就不能得到。
延遲導致多個屏幕的結果閃爍:
my activity shows
- >switch to call
- >end call
- >switch back to my activity
public class OutgoingCallListener extends BroadcastReceiver {
// ...
public void onReceive(final Context context, Intent intent) {
// ...
if(intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
// ...
if(number.equals("*123*")) {
// ...
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
telephonyService.endCall();
}
}, 200);
}
}
}
}
心中已經見過這個特殊號碼撥號功能的其他應用程序,該通話立即結束,而不會閃爍,並切換到應用程序活動。
Q1:有誰知道如何結束通話無延遲?在ACTION_NEW_OUTGOING_CALL
之前還有其他意圖嗎?
Q2:在規格較低的手機(CPU速度較慢,內存較少)的情況下,BroadcastReceiver
的工作方式與在體面的手機上一樣嗎?