Android O Notification导致setLights()被弃用,setLightColor()会眨眼吗?

社区首页 >问答首页 >Android O Notification导致setLights()被弃用,setLightColor()会眨眼吗?问Android O Notification导致setLights()被弃用,setLightColor()会眨眼吗?ENStack Overflow用户提问于 2018-03-16 02:02:46回答 1查看 616关注 0票数 4我有这样的代码:

代码语言:javascript复制 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上,.setLights(Color.YELLOW,5,5)根本不能工作。

javaandroidandroid-notificationsandroid-8.0-oreo关注问题分享EN回答 1推荐最新Stack Overflow用户发布于 2019-09-04 10:48:55

你不能-看起来Android API不再允许自定义闪烁模式。

收藏分享票数 1EN页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持原文链接:https://stackoverflow.com/questions/49306339

复制相关文章

友情链接: