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

标签 java android android-notifications android-8.0-oreo

我有这个代码:

    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/

相关文章:

java - 将二进制数乘以二

android - 如何在android应用程序中更改背景颜色

java - NestDK 无法初始化和更新 SmokeCOAlarm 对象

android - 如何从我们的 Android 应用程序中删除其他应用程序缓存?

Android 自定义通知布局在选项卡后面修剪

java - 使用正则表达式格式化 csv

java - 使用 ServletContext 的 session 对象

android - 应用关闭时推送通知不振动

java - 如何忽略测试方法缺少@throws 的CheckStyle 警告?

android - 我如何在android中设置不闪烁的通知灯