我有这个代码:
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/