How to create a notification without icon in the statusbar or simply hide it?

前端 未结 5 1542
闹比i
闹比i 2021-01-02 00:42

I\'d like to know how to create a notification that doesn\'t show the icon in the statusbar.

There is a way to hide it?

5条回答
  •  失恋的感觉
    2021-01-02 01:17

    .setPriority with parameter PRIORITY_MIN will make this possible.

    NotificationCompat notification = new NotificationCompat.Builder(this)
                    .setContentTitle(getString(R.string.app_name))
                    .setContentText(getString(R.string.notification_text))
                    .setSmallIcon(R.mipmap.ic_launcher)
    
                    //Show the notification only in NotificationDrawer.
                    //Notification will not be shown on LockScreen as well as Hidden Icon on StatusBar.
                    .setPriority(Notification.PRIORITY_MIN)
    
                    .build();
    

提交回复
热议问题