I am trying to implement the ConnectionService. When I add new incoming call I get the system UI to receive or to reject a call.
var handle = account.accountHandle
val extras = Bundle()
extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle)
val manager = getSystemService(Context.TELECOM_SERVICE) as TelecomManager
manager.addNewIncomingCall(handle, extras)
I register the account like this
fun registerConnectionService() {
val manager = getSystemService(Context.TELECOM_SERVICE) as TelecomManager
val connectionServiceId = getConnectionServiceId()
val componentName =
ComponentName(applicationContext, PhoneConnectionService::class.java)
val phoneAccountHandle = PhoneAccountHandle(componentName, connectionServiceId)
val builder = PhoneAccount.builder(
phoneAccountHandle,
this.resources.getText(R.string.app_name)
)
val uri = Uri.fromParts("tel", "123456789", null)
builder.setSubscriptionAddress(uri)
builder.setAddress(uri)
builder.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
builder.setShortDescription("Short description")
phoneAccount = builder.build()
manager.registerPhoneAccount(phoneAccount)
}
I know that to give custom UI i need to set this
builder.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
ConnectionService code when receive the call
@Override
public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
final CallConnection connection = new CallConnection(this);
Bundle extras = new Bundle();
connection.setAddress(request.getAddress(), PRESENTATION_ALLOWED);
connection.setVideoState(VideoProfile.STATE_AUDIO_ONLY);
connection.setExtras(extras);
connection.setConnectionCapabilities(Connection.CAPABILITY_SUPPORT_DEFLECT);
connection.setRingbackRequested(true);
connection.setRinging();
return connection;
}
but still this method not getting called in my CallConnection class which extend the Connection.
onShowIncomingCallUi
Any solution that How can I implement the Custom UI using ConnectionSerivice?