2

我想检测 android 应用程序中的拨出电话。实际上我可以检测到拨出电话,但它也适用于来电,我不希望这样。我需要它只为传出工作。这是我的代码....

boolean ringing = false;
boolean offhook = false;

public void onCallStateChanged(int state, String incomingNumber) {

   switch (state) {


    case TelephonyManager.CALL_STATE_IDLE:

 if((!ringing)&& offhook){
              ///incomming call
         }
          break;
case TelephonyManager.CALL_STATE_RINGING:

    callerPhoneNumber = incomingNumber;
 Log.d(TAG, "RINGING");
 ringing = true;
 offhook = false;     
 break;

   case TelephonyManager.CALL_STATE_OFFHOOK:

 Log.d(TAG, "OFFHOOK");
 offhook = true;
 ringing = false;
 break;
}
4

1 回答 1

6

您可以为android.intent.action.NEW_OUTGOING_CALL.

见这里示例代码可用

于 2010-12-07T15:03:53.877 回答