How to Schedule Notification in Android

NOT FOR USE IN OREO+ (edit) The answers above are good – but don’t consider the user’s potential to restart the device (which clears PendingIntent’s scheduled by AlarmManager). You need to create a WakefulBroadcastReceiver, which will contain an AlarmManager to schedule deliver a PendingIntent. When the WakefulBroadcastReceiver handles the intent – post your notification and … Read more

Notification passes old Intent Extras

You are sending the same request code for your pending intens. Change this: PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); To: PendingIntent contentIntent = PendingIntent.getActivity(context, UNIQUE_INT_PER_CALL, notificationIntent, 0); intents are not created if you send the same params. They are reused.

Android notification with buttons on it

I am glad to post it! After working all night I found something. So, here we go! 1. Create an xml layout file for your notification. 2. Create the notification using the Notification.Builder. After adding everything you want (icons, sounds, etc) do this: //R.layout.notification_layout is from step 1 RemoteViews contentView=new RemoteViews(ctx.getPackageName(), R.layout.notification_layout); setListeners(contentView);//look at step … Read more

Android Color Notification Icon

I found the answer to my question here: https://stackoverflow.com/a/44950197/4394594 I don’t know entirely what the problem was, but by putting the huge png that I was using for the icon into the this tool https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=image&source.space.trim=1&source.space.pad=0&name=ic_skylight_notification and by placing the generated icons it gave into my mipmap folder, I was able to get the setColor(…) property … Read more

Create Custom Big Notifications

Update due to API changes: From API 24 on, the Notification.Builder contains a setCustomBigContentView(RemoteViews)-method. Also the NotificationCompat.Builder (which is part of the support.v4 package) contains this method. Please note, that the documentation for the NotificationCompat.Builder.setCustomBigContentView states: Supply custom RemoteViews to use instead of the platform template in the expanded form. This will override the expanded … Read more

Android multiple line notification like Gmail app

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon) .setContentTitle(“Event tracker”) .setContentText(“Events received”) NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); String[] events = {“line 1″,”line 2″,”line 3″,”line 4″,”line 5″,”line 6”}; // Sets a title for the Inbox in expanded layout inboxStyle.setBigContentTitle(“Event tracker details:”); … // Moves events into the expanded layout for (int i=0; i < events.length; i++) { inboxStyle.addLine(events[i]); … Read more