logo
On this page

Set a leave confirmation dialog


Video Conference Kit (ZegoUIKitPrebuiltVideoConference) leaves a conference by default when the user clicks the Leave button or the Android’s Back button.

If you want to add a confirmation dialog box to double confirm whether the user wants to leave a conference, you can use the leaveConfirmDialogInfo config. After configuring this parameter, a confirmation dialog box with the default style will pop up before leaving or ending the conference, showing the confirmation info you set.

The effect will be like this:

Here is the reference code:

Untitled
public class ConferenceActivity extends AppCompatActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_conference);

    long appID = YourAppID;
    String appSign = YourAppSign;
    String userID = userID;
    String userName = userID;
    String conferenceID = "testConferenceID";

    // Modify your custom configurations here.
    ZegoUIKitPrebuiltVideoConferenceConfig config = new ZegoUIKitPrebuiltVideoConferenceConfig();
    ZegoLeaveConfirmDialogInfo leaveConfirmDialogInfo = new ZegoLeaveConfirmDialogInfo();
    leaveConfirmDialogInfo.title = "Leave the conference";
    leaveConfirmDialogInfo.message = "Are you sure to leave the conference?";
    leaveConfirmDialogInfo.cancelButtonName = "Cancel";
    leaveConfirmDialogInfo.confirmButtonName = "Confirm";
    config.leaveConfirmDialogInfo = leaveConfirmDialogInfo;

    ZegoUIKitPrebuiltVideoConferenceFragment fragment = ZegoUIKitPrebuiltVideoConferenceFragment
            .newInstance(appID, appSign, userID, userName, conferenceID, config);

    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.fragment_container, fragment)
            .commitNow();
  }
}
1
Copied!

If you want to listen for leave events, for example, to save the conference recording when leaving the conference, ZegoUIKitPrebuiltVideoConference provides an setLeaveVideoConferenceListener method that will be triggered when the conference ends. And sure, you can also implement custom business logic in the setLeaveVideoConferenceListener.

On this page

Back to top