0

下面是我的气泡通知代码,

Notification.BubbleMetadata bubbleData =
                    new Notification.BubbleMetadata.Builder()
                            .setIcon(Icon.createWithResource(this, R.drawable.notification_logo))
                            .setIntent(incomingCallPendingIntent)
                            .build();



// Create notification
            Person chatBot = new Person.Builder()
                    .setBot(true)
                    .setName("BubbleBot")
                    .setImportant(true)
                    .build();

            Notification.Builder builder =
                    new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
                            .setContentIntent(incomingCallPendingIntent)
                            .setLargeIcon(getCircleBitmap(drawable.getBitmap()))
                            .setOngoing(true)
                            .setColor(ContextCompat.getColor(context, R.color.blue))
                            .setContentTitle(displayName)
                            .setContentText("Incoming call from "+number)
                            .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE)
                            .setFullScreenIntent(incomingCallPendingIntent, true)
                            .setSmallIcon(R.drawable.notification_logo)
                            .setAutoCancel(false)
                            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE))
                            .setVibrate(vibrate)
                            .setCategory(NotificationCompat.CATEGORY_CALL)
                            .setSmallIcon(R.drawable.notification_logo)
                            .addAction(0,"Answer",answerPendingIntent)
                            .addAction(0,"Cancel",cancelPendingIntent)
                            .setBubbleMetadata(bubbleData)
                            .addPerson(chatBot)
            startForeground(2,builder.build());

在此,不推荐使用 setDefaults、setSound、setVibrate、addAction。

并且在收到来电通知时,点击通知无法获得全屏意图。而不是那个白屏来来去去。同时操作按钮工作正常。只有在设备处于请勿打扰模式时才能看到全屏意图活动。我不知道我的代码有什么问题。任何人都可以帮我解决这个问题。提前致谢。

如果有人遇到这个问题,那么请分享你的想法

4

0 回答 0