Using Android SDK

You can download the archive with application example using the following link: Demo project download.

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:
    1. allprojects {
    2. repositories {
    3. jcenter()
    4. mavenCentral() //add this line
    5. }
    6. }
  • Edit build.gradle and add voximplant-sdk as compile files target in dependencies section:
    1. dependencies {
    2. ...
    3. compile 'com.voximplant:voximplant-sdk:2.1.5'
    4. }

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:

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

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:

  2. client.connect();

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

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

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:

  2. client.login("", "mypass");

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

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

Making calls

Use startCall method to initiate outgoing call:

  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);

Receiving calls

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

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

Handling audio interruptions

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

For more information, please read our reference documentation.