Changing LED color for notifications

前端 未结 8 1957
囚心锁ツ
囚心锁ツ 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:27

    You can use this code:

    private static final int LED_NOTIFICATION_ID= 0; //arbitrary constant
    
    private void RedFlashLight() {
        NotificationManager nm = (NotificationManager) getSystemService( NOTIFICATION_SERVICE);
        Notification notif = new Notification();
        notif.ledARGB = 0xFFff0000;
        notif.flags = Notification.FLAG_SHOW_LIGHTS;
        notif.ledOnMS = 100; 
        notif.ledOffMS = 100; 
        nm.notify(LED_NOTIFICATION_ID, notif);
    }
    

    Instead of using ARGB value as the example show, you can use int property inside android.graphics.Color class to get the color as well (e.g. Color.WHITE)

提交回复
热议问题