我有这段代码:
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();
如何设置像被删除的.setLights(Color.YELLOW,5,5)
一样的延迟?因为在Android O上,.setLights(Color.YELLOW,5,5)
根本不起作用。
答案 0 :(得分:0)
您不能-似乎Android API不再允许自定义闪烁模式。