gpt4 book ai didi

android - 振铃状态去电

转载 作者:搜寻专家 更新时间:2023-11-01 08:55:14 24 4
gpt4 key购买 nike

我有以下代码,我已经读到,当两方之间的电话接通时,拨出电话的振铃状态处于 Activity 状态,另一方实际上可以看到您正在调用并接听电话。空闲状态是通话断开时,摘机状态是您按下按钮拨号的时刻。我正在进入摘机和空闲状态,但无法进入振铃状态。可能是什么问题? .任何帮助将不胜感激。

public void onReceive(final Context context, Intent intent) {
TelephonyManager Tm=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Tm.listen(new PhoneStateListener(){
public void onCallStateChanged(int state,String number) {
super.onCallStateChanged(state, number);
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
//when Idle i.e no call
Toast.makeText(context, "Phone state Idle", 1).show();

break;
case TelephonyManager.CALL_STATE_OFFHOOK:

//when Off hook i.e in call
//Make intent and start your service here
Toast.makeText(context, "Phone state Off hook", 1).show();

break;
case TelephonyManager.CALL_STATE_RINGING:
Toast.makeText(context, "Phone state Ringing", 1).show();
break;


default:
break;
}
}

},PhoneStateListener.LISTEN_CALL_STATE);

最佳答案

TelephonyManager.CALL_STATE_RINGING 用于来电。它不是用于拨出电话的另一方振铃。

TelephonyManager.CALL_STATE_RINGING 将在您有来电且电话响铃时触发。

也供您引用。没有公共(public)api来检测对方呼出电话的振铃状态。

关于android - 振铃状态去电,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19509292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com