CALL_STATE_OFFHOOK调用了两次

时间:2016-08-26 07:19:34

标签: android

我正在开发一款确定来电或来电的应用。不理解为什么CALL_STATE_OFFHOOK在通话期间呼叫两次。请帮助

        switch (state) {
        case TelephonyManager.CALL_STATE_IDLE:
            startedCall=false;
            log.info("state_idle");
            // log.info("onCallStateChanged  CALL_STATE_IDLE");
            /* Intent idle = new Intent(context, BackgroundServices.class);
             context.stopService(idle);*/

           // Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show();
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            log.info("onCallStateChanged  CALL_STATE_OFFHOOK");
            if(!startedCall){
                log.info("it is a outgoing call");
            }
             if (startedCall){
                log.info("it is a incoming call");
            }
            /* Intent offHook = new Intent(context, BackgroundServices.class);
             context.startService(offHook);*/


            //Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show();
            break;
          case TelephonyManager.CALL_STATE_RINGING:
              startedCall = true;
              log.info("call state ringing");
            //Toast.makeText(context, "Phone state Ringing", Toast.LENGTH_LONG).show();
            break;
        }
}`

1 个答案:

答案 0 :(得分:0)

我想问一下你解决了这个问题吗?因为我遇到了同样的问题,我不知道如何解决