0

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

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 的对话框?

4

1 回答 1

1

当您在振铃阅读通话记录后达到理想状态并获得呼叫类型时,如果未接,则类型为 3,如果被拒绝,则类型为 5

于 2013-03-13T06:19:28.330 回答