The performance of the service you select is going to affect the overall impression of your product so, IM part has to be perfect. Major players use custom technologies with encrypted technologies and optimized resource distribution, but we’ll try to figure out the way to integrate a voice call/IM service into a generic Android application and do it on-the-go.
The service I will try to implement into my app is called Sinch. The Sinch SDK is a cloud-based product that allows developers easily add voice calling and instant messaging to their mobile apps. It handles all the complexity of signalling and audio management while providing the freedom to create a stunning user interface.
Getting Started
1. Register a Sinch Developer account at http://www.sinch.com/signup.
2. Set up a new application using the Dashboard, where you can then obtain an Application Key and an Application Secret.
You can download the Sinch SDK at www.sinch.com/download/. It contains a binary library, a user guide, and calling and instant messaging apps reference documentation.
3. Copy the entire libs folder to your project’s root directory.
4. Right-click the jar-files and select ‘Add As Library’.
5. Create a new folder under src/main and name it jniLibs.
6. Move the armeabi-v7a, arm64-v8a, x86 and x86_64 folders into the newly created jniLibs folder.
You need a minimum set of permissions for the app to use the Sinch SDK. These are specified in the AndroidManifest.xml file. If the calling functionality will be used, all five permissions listed here are necessary. However, if the calling functionality isn’t used, the last three (RECORD_AUDIO, MODIFY_AUDIO_SETTINGS and READ_PHONE_STATE) can be omitted.
Creating a Video Stream Phone Call
To set up a video stream phone call:
1. Open the Sinch Dashboard and copy your credentials:
2. Then paste it to SinchService.java:
3. Create activities to put the calling information into. Nothing special, just an onclick event call method:
4. Let’s specify who are we making a call to:
5. Create PlaceActivity.class and make a call:
6. Set up the screens for making and receiving calls:
7. Create some CallActivity.class. Set up the UI with video and update it:
Where SinchCallListener() is:
At this point you can control all the things you want. Now let’s add video to the screen:
Also configure IncomingcallActivity the same way CallActivity.class is:
Conclusion
Performance testing tips:
1. Video call testing. You will require another device and a different Sinch user logged in on it.
2. Create User1 on device1 and User2 on device2.
3. As User1 type User2’s username and click Call.
4. As User2 you will receive an incoming call from User1. Tap “Answer”.
5. Now User1 and User2 are video chatting! Either party can click Hang Up to end the video call.
To sum it all up, Sinch is a great library, one of the best for video phone call application service. If you are not into inventing a bicycle, save your time and money – try it out.
Go to GitHub for some additional information.