logo
On this page

Call invitation config

Customize the call ringtone

Ringtone for call invitation

If you want to set the call ringtone for receiving incoming call invitations or sending outgoing call invitations, you can use the incomingCallRingtone and outgoingCallRingtone config in the ZegoUIKitPrebuiltCallService.

Note
  • To set the ringtone, put the audio file in the directory [your_project]/app/src/main/res/raw.
    (If there is no raw folder in the res directory, create a raw folder.)
  • Remove the audio file suffix when you specify the file path in the code. (E.g., specify the path as "incomingCallRingtone" if the file name is incomingCallRingtone.mp3, just like the reference code below.)

Here is the reference code:

With call invitation
public class MainActivity extends AppCompatActivity {
    long appID = YourAppID;
    String appSign = YourAppSign;
    String userID = "userID";
    String userName = "userName";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initCallInviteService();
    }

    public void initCallInviteService() {
        // Modify your custom configurations here.
        ZegoUIKitPrebuiltCallInvitationConfig callInvitationConfig 
            = new ZegoUIKitPrebuiltCallInvitationConfig();
            
        callInvitationConfig.incomingCallRingtone = "incomingCallRingtone";
        callInvitationConfig.outgoingCallRingtone = "outgoingCallRingtone";

        ZegoUIKitPrebuiltCallService.init(getApplication(), appID, appSign, userID, userName,
            callInvitationConfig);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ZegoUIKitPrebuiltCallService.logout();
    }
}
1
Copied!

Hide the decline button

To hide the Decline button when receiving incoming call invitations, set the showDeclineButton to false.

With call invitation
public class MainActivity extends AppCompatActivity {
    long appID = YourAppID;
    String appSign = YourAppSign;
    String userID = "userID";
    String userName = "userName";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initCallInviteService();
    }

    public void initCallInviteService() {
      ZegoUIKitPrebuiltCallInvitationConfig callInvitationConfig = new ZegoUIKitPrebuiltCallInvitationConfig();
      callInvitationConfig.showDeclineButton = false;
      ZegoUIKitPrebuiltCallService.init(getApplication(), appID, appSign, userID, userName,callInvitationConfig);
    }
}
1
Copied!

Customize the background of the call incoming or outgoing page

To customize the background of the call incoming or outgoing page, use outgoingCallBackground and incomingCallBackground in ZegoUIKitPrebuiltCallInvitationConfig.

With call invitation
public class MainActivity extends AppCompatActivity {
    long appID = YourAppID;
    String appSign = YourAppSign;
    String userID = "userID";
    String userName = "userName";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initCallInviteService();
    }

    public void initCallInviteService() {
      ZegoUIKitPrebuiltCallInvitationConfig callInvitationConfig = new ZegoUIKitPrebuiltCallInvitationConfig();
      callInvitationConfig.outgoingCallBackground = new ColorDrawable(Color.BLUE);
      callInvitationConfig.incomingCallBackground = new ColorDrawable(Color.GREEN);
      ZegoUIKitPrebuiltCallService.init(getApplication(), appID, appSign, userID, userName,callInvitationConfig);
    }
}
1
Copied!

Modify user interface text

Call Kit (ZegoUIKitPrebuiltCallInvitationConfig)'s UI text provided by the internal components is editable, to modify those, use the translationText config.

Here is the reference code:

With call invitation
public class MainActivity extends AppCompatActivity {
    long appID = YourAppID;
    String appSign = YourAppSign;
    String userID = "userID";
    String userName = "userName";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initCallInviteService();
    }

    public void initCallInviteService() {
      ZegoUIKitPrebuiltCallInvitationConfig callInvitationConfig = new ZegoUIKitPrebuiltCallInvitationConfig();
      callInvitationConfig.translationText.incomingCallPageDeclineButton = "Decline";
      callInvitationConfig.translationText.incomingCallPageAcceptButton = "Accept";
      ZegoUIKitPrebuiltCallService.init(getApplication(), appID, appSign, userID, userName,callInvitationConfig);
    }
}
1
Copied!

Customize the call configuration

When using the call invitation feature, if the default call configuration (ZegoUIKitPrebuiltCallInvitationConfig) does not your needs, you can customize the configuration of ZegoUIKitPrebuiltCallConfig by setting up the ZegoUIKitPrebuiltCallConfigProvider. Here is a reference code:

With call invitation
public class MainActivity extends AppCompatActivity {
    long appID = YourAppID;
    String appSign = YourAppSign;
    String userID = "userID";
    String userName = "userName";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initCallInviteService();
    }

    public void initCallInviteService() {
        ZegoUIKitPrebuiltCallInvitationConfig callInvitationConfig = new ZegoUIKitPrebuiltCallInvitationConfig();
        ZegoUIKitPrebuiltCallService.init(getApplication(), appID, appSign, userID, userName,callInvitationConfig);

        callInvitationConfig.provider = new ZegoUIKitPrebuiltCallConfigProvider() {
            @Override
            public ZegoUIKitPrebuiltCallConfig requireConfig(ZegoCallInvitationData invitationData) {
                ZegoUIKitPrebuiltCallConfig config = ZegoUIKitPrebuiltCallInvitationConfig.generateDefaultConfig(
                        invitationData);
                // Modify the config settings here according to your business needs
            }
        }
    }
}
1
Copied!

Set the call automatically ends when initiator leaves

By default, a call continues after the initiator leaves. To configure the call to automatically end when the initiator exits, set the ZegoUIKitPrebuiltCallInvitationConfig.endCallWhenInitiatorLeave property to true.

With call invitation
ZegoUIKitPrebuiltCallInvitationConfig callInvitationConfig = new ZegoUIKitPrebuiltCallInvitationConfig();

callInvitationConfig.endCallWhenInitiatorLeave = true;

ZegoUIKitPrebuiltCallService.init(getApplication(), appID, appSign, userID, userName,callInvitationConfig);
1
Copied!