拨出电话的状态是什么

时间:2012-03-07 20:17:46

标签: android android-intent

我想在激活拨​​出电话后启动新活动(NEW_OUTGOING_CALL)。但是我不知道我应该在我创建的PhoneStateListener类中启动新活动的位置(方法onCallStateChanged)我从哪里开始我的意图?CALL_STATE_IDLE?CALL_STATE_OFFHOOK?

public void onCallStateChanged(int state, String incomingNumber) {
    switch (state) {
    case TelephonyManager.CALL_STATE_IDLE: 
        Log.d("System out", "IDLE");
        NOTOFFHOOK = true;      
        break;
    case TelephonyManager.CALL_STATE_OFFHOOK:  method called
        Log.d("System out", "OFFHOOK, it flag: " + NOTOFFHOOK);

        if (NOTOFFHOOK == false) {
            // do your work on receiving call.
        }
        break;
    case TelephonyManager.CALL_STATE_RINGING:   
        Log.d("System out", "RINGING");
        // do your work while ringing.

        break;
    }
}

1 个答案:

答案 0 :(得分:0)