如何知道来电是否被拒绝或被遗漏

时间:2013-03-13 06:11:22

标签: android

我想检测呼叫是否被遗漏或是否被拒绝使用呼叫状态。

public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);

    switch (state) {
        case TelephonyManager.CALL_STATE_IDLE:
            //when Idle i.e no call   
            if(flag==2){
                Toast.makeText(context,"Missed Call", Toast.LENGTH_LONG).show();
            flag=0;
            }else{
                Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show();
            }

            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            // flag=0;
            // when Off hook i.e in call
            // Make intent and start your service here
            Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show();
            flag=1;
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            //when Ringing
            Toast.makeText(context, "Phone state Ringing", Toast.LENGTH_LONG).show();
            flag=2;
            break;
        default:
            break;
    }               
}

如何弹出Call_STATE_RINGING的对话框?

1 个答案:

答案 0 :(得分:1)

当您在振铃读取通话记录后达到理想状态并获得呼叫类型(如果错过)它具有类型3并且如果被拒绝类型5