如何使用PhoneStateListener识别已拒绝的呼叫和未接来电?在我的代码中,我发送短信只有被拒绝的电话而不是未接电话。请验证以下代码。
class PhoneStateChangeListener extends PhoneStateListener{
public static boolean wasRinging;
SmsManager smsManager = SmsManager.getDefault();
@Override
public void onCallStateChanged(int state, String incomingNumber) {
switch(state){
case TelephonyManager.CALL_STATE_RINGING:
Log.e("pppp", "RINGING");
// Ringing
wasRinging=false;
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.e("Lifttttttt", "OFFHOOK");
//Received calls
wasRinging = true;
break;
case TelephonyManager.CALL_STATE_IDLE:
Log.e("Endddddddd", "IDLE");
if(!wasRinging ){
//Missed or Rejected calls
}
wasRinging = true;
break;
}
super.onCallStateChanged(state, incomingNumber);
}
}
编辑:有可能吗?请给重播。感谢。