Changing LED color for notifications

前端 未结 8 1966
囚心锁ツ
囚心锁ツ 2020-12-04 15:56

I am basically just experimenting with Android development, and a couple of days ago I came across this app called \"Go SMS Pro\", which, among other things, can set up noti

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 16:29

    FLAG_SHOW_LIGHTS and Notification.Builder.setLights(int,int,int); are deprecated since Android O ( API level 26 ) If you plan to use this feature in API level 26 or greater have look at NotificationChannel

    Example :

    NotificationChannel mChannel = new NotificationChannel(id, name, importance);
    .....
    .....
    mChannel.enableLights(true);
    // Sets the notification light color for notifications posted to this
    // channel, if the device supports this feature.
    mChannel.setLightColor(Color.RED);
    

    But in this new implementation You may not have control over LED on milli-seconds & LED off milli-seconds it will be dependent on hardware.

提交回复
热议问题