Call requires API level 16 (current min is 14): android.app.Notification.Builder#build

pt2121 picture pt2121 · May 8, 2013 · Viewed 36.6k times · Source

enter image description hereThe documentation says Notification.Builder is Added in API level 11. Why I get this lint error?

Call requires API level 16 (current min is 14): android.app.Notification.Builder#build

notification = new Notification.Builder(ctx)
                .setContentTitle("Title").setContentText("Text")
                .setSmallIcon(R.drawable.ic_launcher).build();

Manifest:

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="17" />

Am I missing something?

Correct me if I am wrong but the API is added in level 11, right? Added in API level 11

Answer

stinepike picture stinepike · May 8, 2013

NotificationBuilder.build() requires API Level 16 or higher. Anything between API Level 11 & 15 you should use NotificationBuilder.getNotification(). So use

notification = new Notification.Builder(ctx)
                .setContentTitle("Title").setContentText("Text")
                .setSmallIcon(R.drawable.ic_launcher).getNotification();