Reputation: 19
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?
Upvotes: 0
Views: 66
Reputation: 1
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);
Upvotes: 0
Reputation: 1923
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
Upvotes: 1