无论我尝试了什么,都没有通知灯。 我正在运行Android 26 Oreo。 我的手机只显示短信和未接来电的闪光灯提醒。
有没有方法可以控制 LED 灯?
String CHANNEL_ID = "my_channel_01";
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
CharSequence name = "Name"; // The user-visible name of the channel.
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
mChannel = new NotificationChannel("my_channel_01", name, importance);
mChannel.enableLights(true);
mChannel.setLightColor(Color.GREEN);
mChannel.shouldShowLights();
nm.createNotificationChannel(mChannel);
}
Notification notif = new Notification.Builder(MainActivity.this)
.setSmallIcon(R.mipmap.ic_launcher_2)
.setContentTitle("Blhas")
.setContentText("Subject")
.setSubText("Subtext")
.setColor(Color.RED)
.setLights(255, 0, 0)
.setContentIntent(pIntent)
.setStyle(new Notification.BigTextStyle().bigText("..."))
.setChannelId(CHANNEL_ID)
.setPriority(Notification.PRIORITY_HIGH)
.build();
nm.notify(LED_NOTIFICATION_ID, notif);
有没有方法可以控制 LED 灯?