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
.
- 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:
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();
}
}
Hide the decline button
To hide the Decline button when receiving incoming call invitations, set the showDeclineButton
to false
.
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);
}
}
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
.
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);
}
}
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:
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);
}
}
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:
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
}
}
}
}
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.
ZegoUIKitPrebuiltCallInvitationConfig callInvitationConfig = new ZegoUIKitPrebuiltCallInvitationConfig();
callInvitationConfig.endCallWhenInitiatorLeave = true;
ZegoUIKitPrebuiltCallService.init(getApplication(), appID, appSign, userID, userName,callInvitationConfig);