# Examples for Android

Here are several examples for Android Studio IDE when developing for Android. You can download them from our GitHub.

# Example 1. Demonstration of the main capabilities of the SDK

A single-page application where all the main features of TrueConf Mobile SDK are implemented:

  1. Initialization and server connection (start).

  2. Manual login (by pressing a button) on the specified server with the user's account and manual logout from the account.

  3. Call a user by their TrueConf ID (callTo).

  4. Ability to receive incoming video calls.

In the TestApp class within onCreate(), we first call the method registerApp(), passing a subclass of Application. We then launch the SDK using the method start().

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

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

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

The call is executed using the method parseProtocolLink with a call string in the String format as its 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 only allows joining existing conferences.

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

# Example 4. Working with User Statuses

The example shows monitoring the statuses of other users on the server.

Example for 2 screens: the first screen is used for connecting to the server and authorization; afterwards, the second screen opens with 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 handle callback in onUserStatusUpdate and onContactListUpdate.

# Example 5. Interface Customization

The example demonstrates how to add buttons to the in-call screen. This is done using the method setNewExtraButtons, which requires an array of TCExtraButton objects as an argument. The list of buttons will visually appear when the "ellipsis" button is pressed during a conference. As an example, 2 buttons are added, which, when pressed, open a new window over the conference window. The first button opens a Fragment, and the second 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 capability to use the send text messages function sendChatMessage and handle the event for incoming messages onChatMessageReceived.

If a message is sent to a user who is offline, it will be delivered 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 server connection is restored.

# Example 7. Customizing the video layout in a conference

The example demonstrates the ability to place your own image and the images of conference participants in a separate Fragment. It shows the independent implementation of conference control buttons, equipment setup before the conference begins, as well as replacing incoming/outgoing call windows with custom Fragments.

The features demonstrated in the example and the code snippets used for this purpose:

  1. Creating a custom incoming call window based on 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 based on a subclass of PlaceCallFragment. If you need to change the behavior when a call is canceled, 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. Control the microphone using the method setDefaultMicEnabled(), etc.

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

  7. Speaker configuration using the method setDefaultSpeakerEnabled(), among others.

  8. Changing the size and coordinates of participants' video windows in a conference.

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