Archie.bpgc
Archie.bpgc

Reputation: 24012

Notifications.Builder in API 10

Notification.Builder builder = new Notification.Builder(this);

builder.setContentIntent(contentIntent)
    .setSmallIcon(R.drawable.ic_launcher)
    .setTicker(notificationMessage)
    .setWhen(System.currentTimeMillis())
    .setAutoCancel(true)
    .setContentTitle(newNotificationsCount + " New Notifications")
    .setContentText(notificationMessage);

Notification notification = builder.getNotification();
nm.notify(R.string.app_name, notification);

This gives error:

Call requires API level 11 (current min is 10): android.app.Notification$Builder#setContentIntent

I downloaded android.support.v4.jar added it to libs folder in the same directory as src and res etc.

right click on this jar from the project explorer and add to build path.

my application has a min api = 10 and target api = 15

Thank you

Upvotes: 3

Views: 6207

Answers (1)

Sam
Sam

Reputation: 86948

The support class for Notification seems to have a different name, NotificationCompat. For your API 10 code you'll need to use:

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

And change your import statement to:

import android.support.v4.app.NotificationCompat.Builder;

Upvotes: 19

Related Questions