如何在android中识别拒绝的呼叫和未接来电?

时间:2013-01-03 07:08:51

标签: android

如何使用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);
   }
}

编辑:有可能吗?请给重播。感谢。

0 个答案:

没有答案