Skip to content Skip to sidebar Skip to footer

Notification Is Not Displayed Using : NotificationCompat.Builder

I have called a method in oncreate method of mainactivity to a method calling notification but the notification is not delivered when the app starts MainActivity oncreate method

Solution 1:

You need to set some icon with your Notification.Builder because without icon your notification will be generated but will not be displayed on status bar

NotificationCompat.Builder builder=new NotificationCompat.Builder(context)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimaryDark))
            .setContentTitle("Have you done it")
            .setContentText("Make sure you do it")
            .setSmallIcon(R.drawable.yourIconID)
            .setStyle(new NotificationCompat.BigTextStyle().bigText("done"))
            .setContentIntent(contentIntent(context))
            .addAction(decided_yes(context)).addAction(decided_no(context));

Solution 2:

You forgot to put a small icon.

.setSmallIcon(R.drawable.my_icon)

Post a Comment for "Notification Is Not Displayed Using : NotificationCompat.Builder"