Java
Connecting to the Session
Now that the credentials have been set up, we need to connect to the session:
- Copy the following code to update the
MainActivityclass:
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
Overview2
Before You Begin3
Configure a Vonage Video Application4
Creating the Project5
Setting Up Authentication6
Connecting to the Session7
Sending a Signal8
Receiving a Signal9
Testing your Code10
Conclusion