Make call
Main rules and information
- View Creation: Ensure that the call view is created after the creation of the dialog. The best way is make call and show an announcement that call is being established. After received the Dialog instance, you can show the Call view.
- Setting Video Renderers: To display local or remote video, use
setLocalSurfaceViewRendererandsetRemoteSurfaceViewRendererafter the dialog has been established. When view is destroyed you should the same functions but with null argument.
Example
Initiating a call
ArrayList<String> mediaList = new ArrayList<>();
mediaList.add(ConpeekClient.CHANNEL_CHAT); // Add chat channel
mediaList.add(ConpeekClient.CHANNEL_VIDEO); // Add video channel
client.makeCall(mediaList); // Initiate the call with specified media types
Handling call events
MyClientEventListener.java:
@Override
public void onMakeCallFailure() {
Toast.makeText(this, "Cannot make the call", Toast.LENGTH_SHORT).show(); // Show failure message
}
@Override
public void onMakeCallSuccess(Dialog dialog) {
Toast.makeText(this, "Calling...", Toast.LENGTH_SHORT).show(); // Show success message
// Set the local video renderer
dialog.setLocalSurfaceViewRenderer(view.findViewById(R.id.exampleViewLocalVideo));
// Set the remote video renderer
dialog.setRemoteSurfaceViewRenderer(view.findViewById(R.id.exampleViewRemoteVideo));
}
Detailed explanation
-
Initiating a Call:
- An ArrayList is created to specify the media types for the call.
- The media types CHANNEL_CHAT and CHANNEL_VIDEO are added to the list.
- The makeCall method of the ConpeekClient instance is invoked with the mediaList to start the call.
-
Handling Call Events:
- onMakeCallFailure: Displays a toast message indicating the call could not be made.
- onMakeCallSuccess: Displays a toast message indicating the call is in progress. It then sets up the video
renderers for local and remote video views:
setLocalSurfaceViewRenderer: Sets the renderer for the local video using the view with the IDexampleViewLocalVideo.setRemoteSurfaceViewRenderer: Sets the renderer for the remote video using the view with the IDexampleViewRemoteVideo.
By following these guidelines and utilizing the provided example, you can successfully initiate and manage calls using the ConpeekClient, ensuring proper setup and handling of video renderers after the call dialog is established.
Example layout
An example SurfaceViewRenderer in XML layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:orientation="vertical">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/exampleViewRemoteVideo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="128dp"
android:layout_marginBottom="128dp"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:layout_editor_absoluteX="0dp" />
...
<org.webrtc.SurfaceViewRenderer
android:id="@+id/exampleViewLocalVideo"
android:layout_width="100dp"
android:layout_height="0dp"
android:layout_margin="4dp"
android:layout_marginStart="108dp"
app:layout_constraintBottom_toBottomOf="@+id/constrainLayoutMeetingInfo"
app:layout_constraintStart_toStartOf="@+id/constrainLayoutMeetingInfo"
app:layout_constraintTop_toTopOf="parent" />
...
</androidx.constraintlayout.widget.ConstraintLayout>
Example of Activity
MainActivity.java:
public class MainActivity extends AppCompatActivity {
public static ConpeekClient client;
public static MyClientEventListener myClientEventListener;
Dialog dialog;
SurfaceViewRenderer localVideo;
SurfaceViewRenderer remoteVideo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
localVideo = findViewById(R.id.localVideo);
remoteVideo = findViewById(R.id.remoteVideo);
String[] permissions = new String[]{android.Manifest.permission.CAMERA, android.Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_PHONE_STATE};
ActivityCompat.requestPermissions(this, permissions, 1);
ArrayList<String> availableMedia = new ArrayList<>();
availableMedia.add(ConpeekClient.CHANNEL_CHAT);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
availableMedia.add(ConpeekClient.CHANNEL_AUDIO);
}
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
availableMedia.add(ConpeekClient.CHANNEL_VIDEO);
}
if (client == null) {
myClientEventListener = new MyClientEventListener(this);
client = ConpeekClient.builder()
.setTenantPluginAPIURL("https://tenantpluginapiserver1.example.conpeek.com")
.setSdkUUID("f7kca40c-aml4-8182-b9cd-6054970e614e")
.setConfigurationID("665447a51594470a6f7725bc")
.setAvailableMedia(availableMedia)
.setDeviceID(UUID.randomUUID().toString())
.setEventListener(myClientEventListener)
.setActivity(this)
.build();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
ArrayList<String> availableMedia = new ArrayList<>();
availableMedia.add(ConpeekClient.CHANNEL_CHAT);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
availableMedia.add(ConpeekClient.CHANNEL_AUDIO);
}
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
availableMedia.add(ConpeekClient.CHANNEL_VIDEO);
}
client.setAvailableMedia(availableMedia);
}
public void setDialog(Dialog dialog) {
this.dialog = dialog;
Handler mainHandler = new Handler(Looper.getMainLooper());
mainHandler.post(() -> {
dialog.setLocalSurfaceViewRenderer(localVideo);
dialog.setRemoteSurfaceViewRenderer(remoteVideo);
});
}
public void onCloseMeeting(View view) {
dialog.disconnect();
}
public void startCall(View view) {
ArrayList<String> media = new ArrayList<>();
media.add(ConpeekClient.CHANNEL_CHAT);
media.add(ConpeekClient.CHANNEL_AUDIO);
media.add(ConpeekClient.CHANNEL_VIDEO);
client.makeCall(media);
}
}
Example of part of ClientEventListener
MyClientEventListener.java:
public class MyClientEventListener implements ClientEventListener {
MainActivity mainActivity;
public MyClientEventListener(MainActivity mainActivity) {
this.mainActivity = mainActivity;
}
@Override
public void onMakeCallFailure() {
}
@Override
public void onMakeCallSuccess(Dialog dialog) {
mainActivity.setDialog(dialog);
}
@Override
public void onDialogStateChanged(String state, String closeReason) {
}
@Override
public void onNewChatMessage(ChatMessage chatMessage) {
}
@Override
public void dialogInfoIWRS(JSONObject jsonObject) {
}
@Override
public void onQueueMemberStateChanged(QueueMemberState queueMemberState) {
}
@Override
public void onProjectStateChanged(ProjectState projectState) {
}
}
Sample application using Conpeek Android SDK
Below is a screenshot of a sample application that was created using the Conpeek Android SDK. You can develop advanced features in your application via integrating with Conpeek platform thanks to Android SDK.

Proceed to the next step: Class/Methods