2012-05-28 138 views
0

可能重複:
How can my android app detect a dropped call?
Detecting outgoing call and call hangup event in android如何知道通話何時結束?

我正在做一個需要啓動的意圖,當通話結束一個應用程序,但我不知道怎麼做, 我在一個Call Reciver中使用它來跟蹤一個新的呼叫:

telephony.listen(imPhoneListener, PhoneStateListener.LISTEN_CALL_STATE); 
+0

http://stackoverflow.com/questions/5497061/detecting-outgoing-call-and-call-hangup-event-in-android –

回答

1

使用TelephonyManager

public void onCallStateChanged(int state, String incomingNumber) { 
       String stateString = "N/A"; 
       switch (state) { 
       case TelephonyManager.CALL_STATE_IDLE: 
        stateString = "Idle"; 
        break; 
       case TelephonyManager.CALL_STATE_OFFHOOK: 
        stateString = "Off Hook"; 
        break; 
       case TelephonyManager.CALL_STATE_RINGING: 
        stateString = "Ringing"; 
        break; 
       } 

       System.out.println("state-:: " + stateString); 
      } 
+0

我怎樣才能recive狀態回到廣播接收器? – Theter

1

簡單地當無線電狀態回到空閒狀態時。但是您無法檢測連接是否未建立。