Using Android SDK

VoxImplant for Android with demo project can be downloaded here

Adding SDK to your application

  • Unpack demo project into temporary dir.
  • At same level as one of your build.gradle files create libs dir and copy voximplantsdk.jar library from demo project into it.
  • Edit build.gradle and add voximplantsdk.jar as compile files target in dependencies section, ex
    1.  
    2. dependencies {
    3. compile 'com.android.support:support-v4:23.1.1'
    4. compile files('libs/voximplantsdk.jar')
    5. }
    6.  
  • Create jniLibs dir at same level as AndroidManifest.xml and copy armeabi-v71/libjingle_peerconnection_so.so and x86/libjingle_peerconnection_so.so libraries from demo project into it. You need to preserve armeabi-v71 and x86 dirs while copying.

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.