Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] How are phone numbers used in Twilio Programmable Voice SDK for Android?

Posted on November 11, 2022 By

Solution 1 :

When you are making app to app calls, your users do not need a phone number. Instead they are identified by the identity that you provide for the user when you generate an access token for them or when you create a push credential (as Stephan points out).

When you create an access token for your app’s user, you provide a TwiML application SID. That TwiML application defines the URL that Twilio will make a request to when placing outbound calls.

When you place a call with the Voice SDK you pass a set of params to the connect method:

HashMap<String, String> params = new HashMap<>();
params.put("to", contact.getText().toString());
ConnectOptions connectOptions = new ConnectOptions.Builder(accessToken)
    .params(params)
    .build();
Voice.connect(VoiceActivity.this, connectOptions, callListener);

You can send any params you like, in the example above we send a param called “to” with a string from an input field in the view. When you place the call, Twilio then sends those parameters to that URL set in the TwiML application.

When your application receives that webhook it needs to return TwiML to Twilio to tell Twilio what to do next. In your case, you need to return TwiML that will use <Dial> and <Client> to connect to another application. In this case, you would take the incoming param “to”, as defined above, and use it as the client identity you want to call.

<Response>
   <Dial>
     <Client>
        <Identity>IDENTITY_FROM_PARAMS</Identity>
      </Client>
    </Dial>
</Response>

That way Twilio will connect the dialling application to the receiving application identified by the identity.

Problem :

I am using the Android Voice SDK to build an app where one user can call another app user. Calls can only be made to other app users (by searching their username and calling them with a simple click).

READ  [FIXED] How to record 5 sec of sound from mic and save it as file. java.Android studio
Powered by Inline Related Posts

(1) In this scenario, are each users provided with a Twilio phone number?

(2) Say user A calls user B. How does Twilio know that user A is calling user B? (Both a general AND technical explanation would be really helpful here). What is the workflow from making that call to answering it?

The current documentation on the Voice API doesn’t explain its technical use in conjunction with Android except for the quickstart Android project on github. However, as this is focused more on implementation rather than technical explanation, there are a few aspects I am still trying to understand like phone numbers not seemingly being used and the other points mentioned above.

Comments

Comment posted by Stephan Branczyk

Do you want your users to use their data/wifi connection to make those calls to each other? Or do you want them to be able to make the calls without using their data/wifi? If they can use data/wifi, then there is no reason to go through the public switched telephone network, and they can just use Twilio as the go-between.

Comment posted by D-I-S-C

Users are able to use their data/wifi to make calls (in fact, it should be the only way). How exactly would Twilio work as a go-between then? I’ve read the documentation but I’m still unclear on the overall workflow from making that call (user A), to Twilio registering/detecting it, forwarding it to user B and user B answering it.

Comment posted by differs

I’ve actually seen this video and other tips as well, but it’s too high level. I’m looking for something more technical and also specific to Android as it

READ  [FIXED] Android adds item on back stack even when its not specified
Powered by Inline Related Posts

Comment posted by TwiML Bins

Thanks so much for the detailed answer. The documentation and the code make a lot more sense now. When creating the URL for the TwiML application, do I need to provide my own URLs or does Twilio provide available URLs? It looks like

Comment posted by templating feature

For a simple implementation, you could certainly do it with TwiML Bins using their

Android Tags:android, twilio

Post navigation

Previous Post: [FIXED] android.media.ImageWriter produces green screen screen on every second posted Image frame
Next Post: [FIXED] android – Notifee native module not found

Related Posts

[FIXED] android – Using `navigation.navigateUp` incorrectly displays burger menu Android
[FIXED] kotlin – Android studio image saving to external storage Android
[FIXED] Create only one instance of fragment while navigating to destinations(android) Android
[FIXED] Android SQLite QUERI to retrieve data from Table A if the data is in Table B too Android
[FIXED] xml – How do I ensure same proportions in any type of screen size for imagebutton in android studio? Android
[FIXED] bluetooth – How can I solve this NullPointer error in my Android app? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme