2012-05-18 38 views
0

嘿我想在通話過程中按1或2。作爲例子,當你打電話給一個呼叫中心,並想按1鍵去銷售部門,而不用點擊這個號碼,但我想在通話過程中有問題地點擊它。在通話期間點擊鍵android

現在我可以調用按鍵並處理通話事件,但它不起作用。

PhoneStateListener myCallListener = new PhoneStateListener(){ 
      @Override 
      public void onCallStateChanged(int state, String incomingNumber) { 
      // the variable incomingNumber holds the number calling. 
      // the state variable holds the state of the phone (Ringing, Idle ...) 
       switch (state) { 
       case TelephonyManager.CALL_STATE_RINGING: 
        Log.e("Incoming_call", incomingNumber+" is calling me ..."); 
        break; 
       case TelephonyManager.CALL_STATE_OFFHOOK: 
        KeyEvent eventDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_1); 
        dispatchKeyEvent(eventDown); 
        // your logic here, right now the incoming caller is logged. 
        Log.e("Out Call", incomingNumber+" is calling me ..."); 
       break; 
       default: 
       break; 
      } 
      super.onCallStateChanged(state, incomingNumber); 
      } 
     }; 
     TelephonyManager phoneManager = (TelephonyManager) 
     this.getSystemService(TELEPHONY_SERVICE); 
     phoneManager.listen(myCallListener, 
     PhoneStateListener.LISTEN_CALL_STATE); 

回答

1

有可能以編程方式撥打電話,並增加雙音多,並暫停在需要:

Intent i = new Intent("android.intent.action.CALL",Uri.parse("tel://" + number + ',' + dtmf)); 

這是不可能的呼叫中間來決定插入DTMF音頻到音頻上行,雖然它是一個requested feature

0

你的代碼將生成一個密鑰下來事件活動,不爲手機應用程序。

據我所知,不可能達到你想要的,但我可能是錯的。但是,如果可能的話,這是一個潛在的問題,因爲任何應用程序都可以在通話過程中發送任何觸摸按鍵,並在用戶不知情的情況下觸發不好的事情。