Notifications
Notifications
Alarms and
Schedulers
Lesson 8
■ Small icon
■ Title
■ Detail text
setPriority(NotificationCompat.PRIORITY_HIGH)
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.android_icon)
.setContentTitle("You've been notified!")
.setContentText("This is your notification
text.");
Intent notificationIntent =
new Intent(this, MainActivity.class);
PendingIntent notificationPendingIntent =
PendingIntent.getActivity(
this,
NOTIFICATION_ID,
notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
.setContentIntent(notificationPendingIntent);
.addAction(R.drawable.ic_color_lens_black_24dp,
"R.string.label",
notificationPendingIntent);
NotificationCompa.BigPictureStyle
mNotifyManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
mNotifyManager.notify(NOTIFICATION_ID, myNotification);
mNotifyManager.cancel(NOTIFICATION_ID);
This work is licensed under a
Android Developer Fundamentals V2 Notifications Creative Commons Attribution 4.0 Inter 44
national License
Design guidelines
If your app sends too many notifications, users will disable
notifications or uninstall the app.
● Relevant: Whether this information is essential for the user.
● Timely: Notifications need to appear when they are useful.
● Short: Use as few words as possible.
● Give users the power to choose -- Use appropriate notification
channels to categorise your notifications.
This work is licensed under a
Android Developer Fundamentals V2 Notifications Creative Commons Attribution 4.0 Inter 45
national License
What's Next?