I am trying to use Twilio
for video calling application, one end is web and another end is android. Using Firebase to trigger push notification from web to android. I need to convert the push notification as Incoming call screen in android application, to do that I have used ConnectionService
which is documented as available from API 23. I have registered PhoneAccount
as below:
TelecomManager tm = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(
new ComponentName(this.getApplicationContext(), MyConnectionService.class),
"AppName");
PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "AppName")
.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER).build();
tm.registerPhoneAccount(phoneAccount);
I registered PhoneAccount for first time with
PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "AppName")
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED).build();
which will work only on API 26, Later I changed it to
PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "AppName")
.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER).build();
Later one worked as expected in API 26 but on lower versions, it gave an exception
java.lang.SecurityException: This PhoneAccountHandle is not registered for this user!
can anybody help with this issue?