Java

Connecting to the Session

Now that the credentials have been set up, we need to connect to the session:

  1. Copy the following code to update the MainActivity class:
public class MainActivity extends AppCompatActivity {
    private static final String TAG = MainActivity.class.getSimpleName();
    private Session session;
    private SignalMessageAdapter messageHistory;
    private EditText messageEditTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        messageEditTextView = findViewById(R.id.message_edit_text);
        ListView messageHistoryListView = findViewById(R.id.message_history_list_view);

        messageHistory = new SignalMessageAdapter(this);
        messageHistoryListView.setAdapter(messageHistory);

        messageEditTextView.setEnabled(false);

        session = new Session.Builder(this, VonageVideoSDKConfig.APP_ID, VonageVideoSDKConfig.SESSION_ID).build();
        session.setSessionListener(sessionListener);
        session.setSignalListener(signalListener);
        session.connect(VonageVideoSDKConfig.TOKEN);
    }
}

Session.Builder() takes our Application ID and Session ID to set up which video session we will be connecting to. This does not immediately connect us to the session, since applications may have some additional bootstrapping before fully connecting.

session.connect() finally tells the SDK to connect to the API. It takes our token, which is our authentication token, and connects us to the API. The other code is mainly for interfacing with the UI.

Basic text chat

Follow this tutorial to build basic text chat from scratch using the Vonage Video API. It is the quickest way to build a proof of concept for this functionality on the video platform.

Steps
1
Overview
2
Before You Begin
3
Configure a Vonage Video Application
4
Creating the Project
5
Setting Up Authentication
6
Connecting to the Session
7
Sending a Signal
8
Receiving a Signal
9
Testing your Code
10
Conclusion