0

I'm trying to show a simple local notification message on Android.Here is my code but I'm not able to make it work.

There is no action:

final Context context = this;
Intent intent = new Intent(this, MainActivity.class);
final PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);

    Notification n=new Notification.Builder(context)
                                    .setContentTitle("Nabeeer?")
                                    .setContentText("Iceriiik")
                                    .setContentIntent(null)
                                    .setContentIntent(pIntent)
                                    .setAutoCancel(true)
                                    .build();

                            NotificationManager notificationManager =
                                    (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

                            notificationManager.notify(0, n);
fobus
  • 1,938
  • 8
  • 29
  • 48

1 Answers1

2

You need to add an icon to your notification:

.setSmallIcon(R.drawable.youricon)

This isn't documented in the official docs: you need to add a small icon, else the notification won't show.

Community
  • 1
  • 1
Jonas Czech
  • 12,018
  • 6
  • 44
  • 65