0

I used to read this topic about NotificationCompat and I know that the contentIntent is required on Gingerbread and below. However, I'm working in android Gingerbread and I don't want to add PendingIntent. What should I do to have the correct notification?
Thanks for your help

NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setAutoCancel(true);
    builder.setContentTitle("Basic notification");
    builder.setContentText(content);
    builder.setSmallIcon(R.drawable.ic_launcher);

    Notification notification = builder.build();
    try {
        NotificationManager manager = (NotificationManager) this
                .getSystemService(NOTIFICATION_SERVICE);

        manager.notify(8, notification);
    } catch (Exception e) {
        Log.i("Exception", e.getMessage()); 
    }

Exception : contentIntent required: pkg=com.example.notificationtutorial id=8 notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x10)

Community
  • 1
  • 1
Linh
  • 433
  • 6
  • 11

1 Answers1

0

You need to set the contentIntent for your notification.

In your case You have to create a PendingIntent and setter PendingIntent in your notification.

notification.contentIntent = notificationIntent;

otherwise you will get the message, that the contentIntent of the notification is null, because it's not set.

The documentation is here:Notification.html#contentIntent

Example: NotificationCompat Example

joselufo
  • 3,393
  • 3
  • 23
  • 37