Examples for Android

TrueConfAbout 6 min

Examples for Android

Here are some examples for Android development using Android Studio. You can download them from our GitHub.

Example 1. Demonstration of the main SDK features

A single-page application implementing the main features of TrueConf Mobile SDK:

  1. Initialization and connection to the server (start).

  2. Manual login (by pressing a button) to the specified server using the user account and manual logout from the account.

  3. Call a subscriber using their TrueConf ID (callTo).

  4. The ability to receive incoming video calls.

In the TestApp class, within the onCreate() method, we first call the method registerApp(), passing in a subclass of Application, and then initiate the SDK with the method start().

In MainActivity, within onCreate(), we call the method setFallbackActivity(), specifying the Activity class to return to if the call ends.

In PlaceholderFragment, we implement the TrueconfListener interface and override its functions to receive callback.

Example 2. Demonstrating the use of trueconf links

The ability to connect to the server and make a call using the trueconf: protocol with automatic login, allowing you to call a specific user via their TrueConf ID or join a specific group conference by its ID.

The call is executed using the method parseProtocolLink, with the call string in String format passed as a parameter.

You can read more about the trueconf: control protocol in this article.

Example 3: Working with Group Conferences

One of the key features of TrueConf Mobile SDK is the ability to participate in video conferences with multiple users simultaneously. Currently, it is only possible to join existing conferences.

The example is the same as the first one, except that instead of using the callTo method to connect to the conference, we use the method joinConf(conferenceId).

Example 4. Working with user statuses

The example shows how to track the status of other users on the server.

An example with 2 screens: the first screen is used for connecting to the server and authorization, followed by a second screen displaying a list of all users from our address book.

The example also demonstrates how to obtain the current user status using the method getUserStatus(user), as well as how to respond to the callback in onUserStatusUpdate and onContactListUpdate.

Example 5: Interface Customization

The example demonstrates how to add buttons to the screen during a call. This is done using the method setNewExtraButtons, where you need to pass an array of objects of type TCExtraButton as an argument. The buttons will visually appear when the "ellipsis" button is pressed in the conference. As an example, two buttons are added that open a new window on top of the conference window when pressed. The first button opens a Fragment, and the second one opens an Activity.

To replace the icons within a call, upload the resources to the drawables folder with the following names:

ic_bluetooth_audio_arrow_off
ic_bluetooth_audio_arrow
ic_bluetooth_audio
ic_call_end
ic_camera_off
ic_camera_on
ic_dyn_arrow_off
ic_dyn_arrow
ic_empty_invoice
ic_headphones_arrow_off
ic_headphones_arrow
ic_headset_mic_arrow_off
ic_headset_mic_arrow
ic_headset_mic
ic_headset
ic_mic_off
ic_mic_on
ic_more_horiz
ic_phone_in_talk_arrow_off
ic_phone_in_talk_arrow
ic_phone_in_talk_off
ic_phone_in_talk
ic_sound_off
ic_sound_on
ic_rotate
ic_minimize_fullscreen
conf_button_back

Example 6. Chat

The example demonstrates the use of the text message sending function sendChatMessage and handling the event for incoming messages onChatMessageReceived.

If a message is sent to a user who is offline, they will receive it as soon as they come online. If a message is sent when there is no connection to the server, it is queued and will be sent once the connection to the server is re-established.

Example 7. Customizing the video layout in a conference

The example demonstrates the ability to display your own image and conference participants' images in a separate Fragment. It shows a custom implementation of conference control buttons, equipment setup before the start of the conference, and the replacement of outgoing/incoming call windows with custom Fragments.

The features demonstrated in the example and the code snippets used:

  1. Creating a custom incoming call window using a subclass of IncomingCallFragment. To modify the behavior when accepting or declining a call, override the onAcceptClick and onDeclineClick methods accordingly.

  2. Customization of the outgoing call window is based on a subclass of the PlaceCallFragment class. To change the behavior when a call is canceled, you need to override the onHangupClick method.

  3. Modifying the conference window based on a subclass of ConferenceFragment.

  4. Resizing the call window using the method setCallLayoutParams.

  5. Managing the microphone using the setDefaultMicEnabled() method, etc.

  6. Camera control using the method setDefaultCameraEnabled(), etc.

  7. Configuring the speaker using the setDefaultSpeakerEnabled() method, among others.

  8. Resizing and positioning video windows of conference participants.

To see how the functionality for changing window sizes and coordinates works, uncomment the contents of the onCalculateCustomLayouts method in MainActivity in the example.