Notification LED shows only when device is locked


During development of an Android app, I would like to use the notification LED for an unobtrusive way of debugging, eg. when something happens, it should switch to red.

I already realized that it is not that easy to use, since I have to use a notification.

This is my code to let it flash in red:

public class MainActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {

    public void buttonClicked(View theButton) {
        switch (theButton.getId()) {

    private void notificationRedlight() {
        Notification notification = new Notification.Builder(this).
                setContentTitle("I love rock and roll")
                .setContentText("So put another dime in the jukebox baby")
        notification.ledARGB = 0xffff0000;
        notification.ledOnMS = 2000;
        notification.ledOffMS = 500;
        notification.flags = Notification.FLAG_SHOW_LIGHTS;
        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.notify(5, notification);

Unfortunately, this only lets the led flash when the screen is off. When I switch it on again, the led goes dark again.

Is there any way to extend the notification leds to "normal operation"?

Android API: 23

asked on Stack Overflow Sep 9, 2019 by Bowi

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0