Android的 - 如何立即结束呼叫与telephonyService? [英] Android - How to immediately endCall with telephonyService?
问题描述
在我的应用程序,有一个特点,结束呼出(并开始其他活动),同时拨打了一定数量(如 * 123 *
)
In my application, there's a feature that ends outgoing call (and starts other activities) while dialing a certain number (e.g. *123*
)
这是目前的工作,但需要200毫秒的延迟。如果没有延迟,意图不能收到。
It's currently working, but requires a 200ms delay. Without the delay, the intent cannot be recieved.
延迟导致多个屏幕的闪烁的结果:
The delay causes a consequence of multiple screen flickers:
我的活动节目
- > 切换调用
- > 结束通话
- > 切换回我的活动
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);
}
}
}
}
我心中已经见过这个特殊号码拨号功能的其他应用程序
,呼叫立即结束wihout最终呼叫提示音,并切换到应用程序的活动无闪烁。
I'v seen other applications with this special-number-dialing feature, the call ends immediately wihout the end-call-beep, and switches to app activity without flickering.
Q1:有谁知道如何结束通话刻不容缓?有没有办法,我们可以在 ACTION_NEW_OUTGOING_CALL
?
Q1: Does anyone know how to end call without delay? Is there another intent that we can catch before ACTION_NEW_OUTGOING_CALL
?
Q2:在手机用低规格(慢CPU,内存少),将广播接收器
的工作方式相同作为一个体面手机?
Q2: On a mobile phone with low specs (slow CPU, less memory), would BroadcastReceiver
work the same way as on a decent phone?
推荐答案
得到的答案......
Got the answer...
要结束一个发送拨打的立即,我们甚至都不需要结束()
从调用 ITelephony
,相反,我们可以简单地使用 setResultData(NULL);
To end an outgoing call immediately, we don't even need to call endCall()
from ITelephony
, instead, we can simply use setResultData(null);
这是不同于手动结束通话或使用结束呼叫,以 setResultData(空)
:
It's different from manually ending a call or using endCall, with setResultData(null)
:
- 没有通知图标或消息
- 没有调用屏幕
- 没有通话时长面包
- 无通话记录
- 无结束通话蜂鸣声
这就像什么都没有发生(如果......没有任何其他的课外活动)。
It's just like nothing happened (if...without any other extra activities).
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*")) {
setResultData(null);
// start other activities
}
}
}
}
这篇关于Android的 - 如何立即结束呼叫与telephonyService?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!