Android Basics – Learn how to use Android Notification Service

In order to send Notification to the user you can use the following steps, which have been explained in the video.

Create a Pending Intent

Intent intent = new Intent(this, MainActivity.class);

TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this);

PendingIntent pendingIntent = taskStackBuilder.
        getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);


Create a Notification object

Notification notification = new Notification.Builder(this)
        .setContentText("Sample Notification")

Use NotificationManager to send the Notification

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, notification);

Source Code available here

Author: Ankur

I am Enthusiastic about Learning new things and sharing my Knowledge. I like programming and have a pretty good background in Computer Science.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: