gpt4 book ai didi

java - Android O 通知 LED setLights() 已弃用,setLightColor() 带有闪烁?

转载 作者:太空宇宙 更新时间:2023-11-04 10:37:38 25 4
gpt4 key购买 nike

我有这个代码:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel("test", getString(R.string.notification_channel_news), NotificationManager.IMPORTANCE_HIGH);

channel.enableLights(true);
channel.setLightColor(Color.YELLOW);
channel.enableVibration(true);
channel.setVibrationPattern(pattern);
channel.setImportance(NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("desc");

Log.e("notif", channel.shouldShowLights() + "");

if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "test")
.setSmallIcon(R.mipmap.ic_launcher)
.setPriority(2)
.setContentTitle(messageTitle)
.setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
.setVibrate(pattern)
.setLights(Color.YELLOW,5,5)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);

Notification not = notificationBuilder.build();

如何设置 LED 的延迟,如已废弃的 .setLights(Color.YELLOW,5,5)?因为在 android O 上,.setLights(Color.YELLOW,5,5) 根本不起作用。

最佳答案

你不能 - Android API 似乎不再允许自定义闪烁模式。

关于java - Android O 通知 LED setLights() 已弃用,setLightColor() 带有闪烁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49306339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com