logo
On this page

Set a hangup confirmation dialog

Call Kit (ZegoUIKitPrebuilt) ends a call by default when the user clicks the End Call button or the Android’s Back button.

If you want to add a confirmation dialog box to double confirm whether the user wants to hang up a call, you can use the hangUpConfirmInfo config: After configuring the hangUpConfirmInfo parameter, ZegoUIKitPrebuilt will pop up a confirmation dialog box with the default style before ending the call, showing the confirmation info you set.

The effect will be like this:

Here is the reference code:

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

    long appID = YourAppID;
    String appSign = YourAppSign;
    String userID = "userID";
    String userName = "userName";
    String callID = "testCallID";

    // Modify your custom configurations here.
    ZegoUIKitPrebuiltCallConfig config = ZegoUIKitPrebuiltCallConfig.oneOnOneVideoCall();
    config.hangUpConfirmDialogInfo = new ZegoHangUpConfirmDialogInfo();
    config.hangUpConfirmDialogInfo.title= "Hangup confirm";
    config.hangUpConfirmDialogInfo.message= "Do you want to hangup?";
    config.hangUpConfirmDialogInfo.cancelButtonName= "Cancel";
    config.hangUpConfirmDialogInfo.confirmButtonName= "Confirm";

    ZegoUIKitPrebuiltCallFragment fragment = ZegoUIKitPrebuiltCallFragment
            .newInstance(appID, appSign, callID, userID, userName, config);

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

If you want to listen for hang-up events, for example, to save the call recording when ending the call, ZegoUIKitPrebuiltCallConfig provides a leaveCallListener, and the leaveCallListener will be triggered when the call ends. And sure, you can also implement custom business logic in the LeaveCallListener.

Previous

Customize the menu bar

Next

Call invitation config

On this page

Back to top