如何检查呼叫是由用户结束还是自动结束?

时间:2014-04-16 19:03:12

标签: java android call phone-state-listener

我想知道是否有办法让用户结束来电(丢弃)或自动结束,因为没有响应(未接来电)。换句话说:我想在出现未接来电时(当通话自动结束时)做一些动作。

1 个答案:

答案 0 :(得分:1)

当出现未接来电时,做那样的事情。在我的代码中,当未接来电出现时我打开了活动。

switch (state) {
    case TelephonyManager.CALL_STATE_IDLE:
        Log.v("idle state", "CALL_STATE_IDLE");

        // CALL_STATE_IDLE ( OpenMissedCallScreen )


        if (ring == true && callReceived == false && CheckMissCall.isRunning== false) {



            flag = true;
            if (prefs.getBoolean("main_state", true))
            {
                Intent inter = new Intent(c, MissCall.class);

            }

        }



        break;
    case TelephonyManager.CALL_STATE_OFFHOOK:

        // CALL_STATE_OFFHOOK ( OpenReceivedCallScreen )
        callReceived = true;



        break;
    case TelephonyManager.CALL_STATE_RINGING:

        ring = true;
        // CALL_STATE_RINGING ( openIncomingCallScreen )


        break;