Android Notification Tutorial with Example

By | August 2, 2019

Android Notification Example Tutorial

What is Notification in Android ?

Notification is a message you can display to the user outside of your application’s normal UI. It is provides short, timely information about the action in the application. it is not running.

Notification are displays the icon, title and some amount of the content text.

Notification is used to NotificationManager Class.Notification is a Alert of Message to user and it is short time display information of user. It is by default removed to use of swipe to removed notification.



Notification Set the use of Properties of NotificationCompat.Builder. it is used to set the icon,title,description in Notification.And create the PendingIntent is used to set the Flag of Notification and then builder to set content Intent of pendingIntent object.

NotificationCompat.Builder class allows easier control over all the flags, as well as help constructing the typical notification layouts.

Properties Of Notification in Android

setSmallIcon(): It is Set the Icon of Notification.

setContentTitle() : It is Set the Title of Notification.

setContentText() : It is used to Set the Text of Notification.

setAutoCancel():  It is used to Cancelable  Notification.

setPriority(): It is used to Set the Priority of Notification.



Example of Notification in Android

Create activity_main.xml File Follow this Code.

Create MainActivity.java File Follow this Code.



Above The Example of Create Simple Notification When you can click the button to display notification. Set the Title Description and icon in the notification of Android.