Adjusting the sample app UI
The Android SDK exposes videos you publish and subscribe to as View objects. You can add these as children of ViewGroup objects in your app. This sample app will use FrameLayout objects (which extend ViewGroup) as containers for the publisher and subscriber views:
In Android Studio, open the
app/res/layout/activity_main.xmlfile. Click the "Text" tab at the bottom of the editor to display the XML code for the file.Replace the file contents with the following code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/subscriber_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/publisher_container"
android:layout_width="90dp"
android:layout_height="120dp"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:background="#CCCCCC"
android:padding="2dp" />
</FrameLayout>
Be sure to replace the entire content of the <TextView> element (through the closing /> tag).
- Now declare
publisherViewContainerandsubscriberViewContaineras properties of the MainActivity class (right after the declaration for thesessionproperty):
private FrameLayout publisherViewContainer;
private FrameLayout subscriberViewContainer;
- Finally, in the existing
onCreate()method, initialize these layout view objects by adding the following lines of code under thesetContentView()method call:
publisherViewContainer = findViewById(R.id.publisher_container);
subscriberViewContainer = findViewById(R.id.subscriber_container);
At this point, your onCreate() method should look like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
publisherViewContainer = findViewById(R.id.publisher_container);
subscriberViewContainer = findViewById(R.id.subscriber_container);
requestPermissions();
}
The steps above merely set up a sample layout for this app. Your own app can add publisher and subscriber views as children of other ViewGroup objects
Basic video chat
Learn the basic concepts of the Vonage Video API platform, including how users can communicate through video, voice, and messaging. Explore a basic Vonage Video API flow.