Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications
by James Talbot, Justin McLean, Jorge Hernandez
Creating a Notification
To create a notification, you can either create one by hand using the Notification class, or use the Notification.Builder interface to create one for you. You use a PendingIntent to specify the action to be performed after the user selects the notification. The Notification.Builder allows you to add up to three buttons with definable actions. The Notification.Builder class contains a lot of other methods that help you create a notification.
Just as you did with the Toast pop-ups, you can create a helper class that sends notifications for you and reduces code duplication. Here, you’ll create a notification as well as display it at a later time.
1. Create a new class called Notify in the helper package by right-clicking ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access