Notification foregroundNote; RemoteViews bigView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notification_layout_big); // bigView.setOnClickPendingIntent() etc.. Notification.Builder mNotifyBuilder = new Notification.Builder(this); foregroundNote = mNotifyBuilder.setContentTitle("some string") .setContentText("Slide down on note to expand") .setSmallIcon(R.drawable.ic_stat_notify_white) .setLargeIcon(bigIcon) .build(); foregroundNote.bigContentView = bigView; // now show notification.. NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotifyManager.notify(1, foregroundNote);
Notification.Builder builder = new Notification.Builder(MainActivity.this);
final String someLongText = "fkdljfdldkfj;ldaksjfkladj;flja;lkjdfljadslfjaddfdsfafjdfad" + "fdl;akjf;lkdf;lkaj;flkjda;lkfjadljflk;adsjfladjflk;dfjlkdjflakdfjdaffjdlfjdjjj" + "adjflkjadlkfjad;lkfjad;sljf;ladkjajlkfjad;lksfjl;akdjf;lkdsajf;lkdjfkadj;flkad" + "jf;lkadjfkldas;lkfja;dljf;lkdasjf;lkadjs;lfjas;ldkfj;lkadsjfl;kadljfl;kasdjf;l" + "jdlskfjklda;fjadslkfj;sdalkfj;ladjf;lajdl;fkajld;kfjlajfl;adjfl;kajdl;fjadl;kfj;"; final Notification.Builder builder = new Notification.Builder(this); builder.setStyle(new Notification.BigTextStyle(builder) .bigText(someLongText) .setBigContentTitle("Big title") .setSummaryText("Big summary")) .setContentTitle("Title") .setContentText("Summary") .setSmallIcon(android.R.drawable.sym_def_app_icon); final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(0, builder.build());
// try this Notification.Builder builder = new Notification.Builder(this);
Notification.Builder builder = new Notification.Builder(this); builder .setWhen(System.currentTimeMillis()) .setSmallIcon(R.mipmap.ic_launcher) //Any icon you want .setContentTitle("TEST") .setContentText("Hello! This is a notification test!") .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)); NotificationManager NoMa = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); NoMa.notify(1, builder.build());
Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle("Big text Notification") .setContentText("Big text Notification") .setSmallIcon(R.drawable.ic_launcher) .setAutoCancel(true) .setContentIntent(pi) // <- this new line .setPriority(Notification.PRIORITY_HIGH) .addAction(R.drawable.ic_launcher, "show activity", pi);
Notification.Builder mBuilder = new Notification.Builder(this) mBuilder.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sound));
private void testNotification() { Notification.Builder builder = new Notification.Builder(this); builder.setSmallIcon(R.drawable.ic_launcher) .setPriority(Notification.PRIORITY_HIGH) .setOngoing(true); builder.setLights(0xff00ff00, 300, 100); NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); manager.notify(1, builder.build()); }
final String someLongText = "......"; final Notification.Builder builder = new Notification.Builder(this); builder.setStyle(new Notification.BigTextStyle(builder) .bigText(someLongText) .setBigContentTitle("Big title") .setSummaryText("Big summary")) .setContentTitle("Title") .setContentText("Summary"); final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(0, builder.build());
Notification.Builder builder=new Notification.Builder(this); builder.setContentIntent(intent) .setSmallIcon(R.drawable.ic_notification).setTicker(context.getResources().getString(R.string.app_name)) .setContentTitle(context.getResources().getString(R.string.app_name)) .setContentText(message); Notification notification = builder.build();
// Notification.Builder is used to create the notification Notification.Builder builder = new Notification.Builder(this); // This set the title of the notification builder.setContentTitle("Title") // This set the content of the notification (the text inside the notification) .setContentText("Content of the notification") // Here you set the icon of the notification .setSmallIcon(R.drawable.ic_action_copy); // Build the notification and save it Notification notification = builder.build(); // To show the notification you need to use the NotificationManager, to get it you should use getSystemService NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // .. then you can use .notify to show the notification // 0 is the ID of the notification, you can use this ID to update the notification later. // notification is the notification to show (you can use builder.build() inside too.) manager.notify(0, notification);
final Notification.Builder builder = new Notification.Builder(this); final int id = 0; // change this w/ your notification id Bitmap placeholder = BitmapFactory.decodeResource(getResources(), R.drawable.your_placeholder_icon);
public class MyNewIntentService extends IntentService { private static final int NOTIFICATION_ID = 3; public MyNewIntentService() { super("MyNewIntentService"); } @Override protected void onHandleIntent(Intent intent) { Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle("My Titel"); builder.setContentText("This is the Body"); builder.setSmallIcon(R.drawable.whatever); Intent notifyIntent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 2, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); //to be able to launch your activity from the notification builder.setContentIntent(pendingIntent); Notification notificationCompat = builder.build(); NotificationManagerCompat managerCompat = NotificationManagerCompat.from(this); managerCompat.notify(NOTIFICATION_ID, notificationCompat); } }
private final int NOTIFICATION_ID = 237; private static int value = 0; Notification.InboxStyle inboxStyle = new Notification.InboxStyle(); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.push_notify_icon); public void buttonClicked(View v) { value ++; if(v.getId() == R.id.btnCreateNotify){ NotificationManager nManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle("Lanes"); builder.setContentText("Notification from Lanes"+value); builder.setSmallIcon(R.drawable.ic_launcher); builder.setLargeIcon(bitmap); builder.setAutoCancel(true); inboxStyle.setBigContentTitle("Enter Content Text"); inboxStyle.addLine("hi events "+value); ncomp.setStyle(inboxStyle); nManager.notify("App Name",NOTIFICATION_ID ,ncomp.build()); } }
String notificationText = String.valueOf(progress[0]) + " %"; Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle("Progress"); builder.setContentText(notificationText);
Notification.Builder builder = new Notification.Builder(this);
public class MyNewIntentService extends IntentService { private static final int NOTIFICATION_ID = 3; public MyNewIntentService() { super("MyNewIntentService"); } @Override protected void onHandleIntent(Intent intent) { Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle("My Titel"); builder.setContentText("This is the Body"); builder.setSmallIcon(R.drawable.ic_notification_appicon); builder.setAutoCancel(true); builder.setLights(Color.GREEN, 500, 500); Intent notifyIntent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 2, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); Notification notificationCompat = builder.build(); NotificationManagerCompat managerCompat = NotificationManagerCompat.from(this); managerCompat.notify(NOTIFICATION_ID, notificationCompat); }
private Notification getNotification(String content) { Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle(getString(R.string.app_name)); builder.setContentText(content); builder.setTicker(content); builder.setSmallIcon(R.drawable.ic_notification_appicon); builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); builder.setDefaults(Notification.DEFAULT_VIBRATE); builder.setAutoCancel(true); builder.setLights(Color.GREEN, 500, 500); // This intent is fired when notification is clicked Intent intent = new Intent(getApplicationContext(), YouMainActvity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); // Set the intent that will fire when the user taps the notification. builder.setContentIntent(pendingIntent); return builder.getNotification(); }
void PushNotificationReceived (object sender, ParsePushNotificationEventArgs e) { var payload = JObject.Parse (e.StringPayload); // Parse the JSON payload Notification.Builder builder = new Notification.Builder (this); builder.SetContentTitle (payload ["alert"].ToString ()); builder.SetContentText (payload ["androidDetail"].ToString ()); // Note: this is another field I added to the Parse Notification builder.SetDefaults (NotificationDefaults.Sound | NotificationDefaults.Vibrate); builder.SetSound (RingtoneManager.GetDefaultUri (RingtoneType.Notification)); builder.SetSmallIcon (Resource.Drawable.small_notification_icon); var largeIcon = BitmapFactory.DecodeResource (Resources, Resource.Drawable.large_notification_icon); builder.SetLargeIcon (largeIcon); var notification = builder.Build (); notification.Defaults |= NotificationDefaults.Vibrate; NotificationManager notManager = (NotificationManager)GetSystemService (Context.NotificationService); notManager.Notify (0, notification); }
topSmallView.addView(topId, viewSmall); Notification.Builder builder = new Notification.Builder(this);