Using Android SDK

VoxImplant for Android with demo project can be downloaded here

Adding SDK to your application

  • If you use previous Android SDK version, please remove all .jar and .so files from your project
  • Unpack demo project into temporary dir
  • At same level as one of your build.gradle files create libs dir and copy voximplant-release.aar library from demo project into it.
  • Edit build.gradle and add voximplant-release.aar and its dependencies as compile files target in dependencies section, ex
    1.  
    2. repositories {
    3. ...
    4. flatDir {
    5. dirs 'libs'
    6. }
    7. }
    8. dependencies {
    9. compile 'com.squareup.okhttp3:okhttp:3.6.0'
    10. compile 'com.google.code.gson:gson:2.8.0'
    11. compile(name: 'voximplant-release', ext: 'aar')
    12. }
    13.  
  • For Android SDK versions prior to 2.1.1 please use these dependencies

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.  
  2. import com.zingaya.voximplant.VoxImplantCallback;
  3. import com.zingaya.voximplant.VoxImplantClient;
  4. import com.zingaya.voximplant.VoxImplantClient.LoginFailureReason;
  5.  
  6. public class MainActivity extends AppCompatActivity {
  7.  
  8. private VoxImplantClient client;
  9.  
  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);
  18.  

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: following code:

  1.  
  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) {
  9.  
  10. client.answerCall(callId);
  11. this.activeCall = new Call(callId, true, videoCall);
  12.  

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.