Search code examples
androidtwiliomobile-application

Android: How to get incoming calls on our device from Twilio,accept and record them


After searching for a long time, I'm going to post this question.

Here, I am going to build an application in android which will have Twilio Voice for making outbound calls and receiving incoming calls to android Application. I've successfully implemented the process of outgoing calls and its working fine too. But When someone calls from traditional phone to one of Twilio powered phone number, Twilio receive the incoming connection through Twilio device and send Asynchronous HTTP request to voice URL configured for that particular number and execute the expected Twiml Instructions. But here, the question is how to integrate this functionality of receiving incoming calls or connections to Twilio number into my android application and record the accepted calls, then how my application will distinguish that call is receiving on a particular number.


Solution

  • Twilio developer evangelist here.

    What I think you're looking for here is how to integrate Twilio Client to allow you to answer phone calls within your application. I recommend you take a look through our quickstart guide on getting started with Twilio Client for Android.

    As for recording the calls, that is something you can do within the TwiML you set up. If you have TwiML that dials onto a Client it would normally look a bit like this:

    <Response>
      <Dial>
        <Client>ClientName</Client>
      </Dial>
    </Response>
    

    And you would want to include a record attribute on the <Dial> element, like so:

    <Response>
      <Dial record="true">
        <Client>ClientName</Client>
      </Dial>
    </Response>
    

    That will record the entire call from the dialling onwards. You can read more about the record attribute here: https://www.twilio.com/docs/api/twiml/dial.

    I hope this helps, let me know if you have any other questions.