Notification implementation for Android

Implementing notifications in Android is simple enough to do. Notifications give your app more richness and you can display messages or other information, even a couple tasks/buttons.

Here’s a very simple notification implementation that consists of simple text and an icon.

public void addNotification(Context context) 
	NotificationCompat.Builder builder =
	         ( new NotificationCompat.Builder(context)
		 .setSmallIcon(R.drawable.notif_icon) //a small image/icon to display with our notification
	Intent notificationIntent = new Intent(context, MainScreen.class);
	PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,

	// Add as notification
	NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

You can also add action buttons to your notifications, see here:


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 )

Google+ photo

You are commenting using your Google+ 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