0

There is the code:

Notification notification = new Notification.Builder(this).setContentTitle("New mail from").setContentText("Text")
.setSmallIcon(android.R.drawable.btn_plus).setLargeIcon(Bitmap.createBitmap(20, 20, null))
.build();

The error reads:

The method build() is undefined for the type Notification.Builde.

I get this code from Google example. What I am doing wrong?

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
  • possible duplicate of [The method build() is undefined for the type Notification.Builder](http://stackoverflow.com/questions/19635081/the-method-build-is-undefined-for-the-type-notification-builder) – Maveňツ Nov 04 '14 at 07:46

2 Answers2

1

it required minimum API level 16 you can increase the minimum API level in AndroidManifest.xml file (incase you are targeting your app only for devices above that)

or you can use NotificationCompat.Builder which comes as support library

Aun
  • 1,883
  • 1
  • 17
  • 26
0

If you are targeting your os after Honeycomb then you will need to implement NotificationCompat.Builder class.

Try this:

           NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

           Notification notification = builder.setContentIntent(contentIntent)
                .setSmallIcon(icon).setTicker(appname).setWhen(when)
                .setAutoCancel(true).setContentTitle(appname)
                .setContentText(message).build();

           notificationManager.notify(0, notification);
Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51