android - 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 没有为这个用户注册!
有人可以帮忙解决这个问题吗?
解决方案
推荐阅读
- android - 无法解决 JitPack 版本的传递依赖
- asynchronous - 如何展平和收集期货迭代器到结果?
- powerbi - 功率查询 (powerbi) 将面板数据(横截面时态数据)转换为带有添加时态列的横截面结构
- vue.js - Vue路由器:在获取数据后运行beforeEach
- typescript - 如何将数字[]与仅包含数字的接口匹配
- next.js - Bootstrap 5 Popover(Next.js)“找不到名称引导程序”
- javascript - Puppeteer:一个一个地抓取多个网址
- c# - NetCore NpgsqlConnection 无法连接到 MacOs 上 docker 容器内的 psql
- php - 我可以实现接口并覆盖接口方法之一的返回类型吗?
- sqlalchemy - Sqlalchemy:使用自定义primaryjoin解决多对多关系的笛卡尔积警告