依据Google官方提供解决方案,使用全局通知来适配:


在来电监听的在Service中添加如下代码
**
* 启动通知
*/
private void startForegroundNotification(final int call_id, final String phone) {
// 构建通知栏构造器
NotificationCompat.Builder mBuilder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
"ForegroundNotificationChannel", NotificationManager.IMPORTANCE_HIGH);
&n

本文介绍如何在Android应用中使用全局通知适配来电监听功能。通过在Service中添加特定代码,创建自定义的通知栏,实现来电时显示通知并提供接听和挂断操作。需添加USE_FULL_SCREEN_INTENT和FOREGROUND_SERVICE权限。
最低0.47元/天 解锁文章
1245





