Pregunta

Quiero detectar llamadas salientes en la aplicación Android. En realidad, yo puedo detectar las llamadas salientes pero también está trabajando para entrante también y no quiero eso. Necesito que funcione sólo para conexiones salientes. Aquí está mi código ....

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;
}
¿Fue útil?

Solución

Puede escribir un receptor de radiodifusión para android.intent.action.NEW_OUTGOING_CALL.

Vea aquí Muestra código está disponible

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top