作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有以下代码,我已经读到,当两方之间的电话接通时,拨出电话的振铃状态处于 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/
我是一名优秀的程序员,十分优秀!