VoxImplant Android SDK Reference

VoxImplant Android SDK lets you embed voice communication into your native Android applications. You can download the archive with application example using the following link Demo project download .

You can make and receive calls using your device's data connection to/from any other endpoint that works with VoxImplant: other mobile app built using VoxImplant Mobile SDK, web application built using the Web SDK, SIP phones and phone numbers all over the world.

Adding SDK to your application

  • If you use previous Android SDK version, please remove all .jar, .so and .aar files from your project
  • Modify build.gradle file that is located at the root level of your project to add mavenCentral() to repositories list.
  • Edit build.gradle and add voximplant-sdk as compile files target in dependencies section, ex:

Initializing SDK

Set requied permissions for application by modifying the AndroidManifest.xml file. Demo project manifest file can be used as a reference for correct permissions list.

In your activity, create instance field of type VoxImplantClient and initialize it as specified in documentation:

  1. import com.zingaya.voximplant.VoxImplantCallback;
  2. import com.zingaya.voximplant.VoxImplantClient;
  3. import com.zingaya.voximplant.VoxImplantClient.LoginFailureReason;
  4.  
  5. public class MainActivity extends AppCompatActivity {
  6.  
  7. private VoxImplantClient client;
  8.  
  9. @Override
  10. protected void onCreate(Bundle savedInstanceState) {
  11. super.onCreate(savedInstanceState);
  12. client = VoxImplantClient.instance();
  13. client.setAndroidContext(getApplicationContext());
  14. client.setCallback(this);
  15. client.setCamera(Camera.CameraInfo.CAMERA_FACING_FRONT);
  16. client.setCameraResolution(320, 240);
  17. }

Object set viw setCallback will later receive all events from SDK, for example ones related to the connection itself, login status, calls and audio status.

Logging in

It's the same as using WebSDK, you need to connect to cloud via:

  1.  
  2. client.connect();
  3.  

As a result onConnectionSuccessful or onConnectionFailedWithError method of callback object will be called:

  1.  
  2. @Override
  3. public void onConnectionSuccessful() {
  4. Log.i("main", "Connected to server");
  5. }
  6.  

After connection is established, use login function to authenticate. For example, when you need to login user myuser to applcation myapp in your VoxImplant account named myaccount with password mypass:

  1.  
  2. client.login("myuser@myapp.myaccount.voximplant.com", "mypass");
  3.  

As a result onLoginSuccessful or onLoginFailed method of callback object will be called:

  1.  
  2. @Override
  3. public void onLoginSuccessful(String displayName) {
  4. Log.i("Logged in successfully");
  5. }
  6.  

Making calls

Use startCall method to initiate outgoing call:

  1.  
  2. String callId = client.createCall("+79261234567", false, null);
  3. Map<String, String> headers = new HashMap<String, String>();
  4. client.startCall(callId, headers);
  5. this.activeCall = new Call(callId, false, false);
  6.  

Receiving calls

When application receives incoming call, onIncomingCall method of callback object is called. Use answerCall method to answer a call with following code:

  1. @Override
  2. public void onIncomingCall(
  3. final String callId,
  4. String from,
  5. String displayName,
  6. final boolean videoCall,
  7. Map<String, String> headers) {
  8.  
  9. client.answerCall(callId);
  10. this.activeCall = new Call(callId, true, videoCall);
  11. }

Handling audio interruptions

Audio interruption happens when an incoming call to Android arrives. If user answers call, application will be suspended and most likely it will be disconnected from server because of timeout.

For more information, please read our reference documentation .