首页 > 解决方案 > ConnectionService PhoneAccount 在 android 中注册的问题

问题描述

我正在尝试Twilio用于视频通话应用程序,一端是 web,另一端是 android。使用 Firebase 触发从 web 到 android 的推送通知。我需要将推送通知转换为 android 应用程序中的来电屏幕,为此我使用ConnectionService了 API 23 中记录的可用信息。我已注册PhoneAccount如下:

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);

我第一次注册 PhoneAccount

PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "AppName")
  .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED).build();

仅适用于 API 26,后来我将其更改为

PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "AppName")
.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER).build(); 

后来一个在 API 26 中按预期工作,但在较低版本上,它给出了一个异常

java.lang.SecurityException: 这个PhoneAccountHandle 没有为这个用户注册!

有人可以帮忙解决这个问题吗?

标签: androidtwilioincoming-callvoip-android

解决方案


推荐阅读