Last active
May 22, 2018 15:41
-
-
Save adriantache/9692aa2d4d5bc32a60e8e06311291a51 to your computer and use it in GitHub Desktop.
Notification Building code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final static String manasia_notification_channel = "Manasia Event Reminder"; | |
//get latest event details | |
String notificationTitle = "Manasia event: " + event.getTitle(); | |
String notificationText = event.getDate() + " at Stelea Spatarul 13, Bucuresti"; | |
//build the notification | |
NotificationCompat.Builder notificationBuilder = | |
new NotificationCompat.Builder(getApplicationContext(), manasia_notification_channel) | |
.setSmallIcon(R.drawable.ic_manasia_small) | |
.setContentTitle(notificationTitle) | |
.setContentText(notificationText) | |
.setContentIntent(pendingIntent) | |
.setAutoCancel(true) | |
.setPriority(NotificationCompat.PRIORITY_DEFAULT); | |
//trigger the notification | |
NotificationManagerCompat notificationManager = | |
NotificationManagerCompat.from(getApplicationContext()); | |
//we give each notification the ID of the event it's describing, | |
//to ensure they all show up and there are no duplicates | |
notificationManager.notify(DBEventID, notificationBuilder.build()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment