Android examples for Android OS:Notification Create
build Notification With Builder
//package com.java2s; import android.annotation.TargetApi; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; import android.os.Build; public class Main { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressWarnings("deprecation") private static Notification buildNotificationWithBuilder( Context context, PendingIntent pendingIntent, String title, String text, int iconId) { android.app.Notification.Builder builder = new android.app.Notification.Builder( context).setContentTitle(title).setContentText(text) .setContentIntent(pendingIntent).setSmallIcon(iconId) .setAutoCancel(true);/*from ww w . j a v a 2 s. com*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { return builder.build(); } else { return builder.getNotification(); } } }