Create custom notification, android

The question:

I want to create a notification that like the red bordered notification in this image:

enter image description here

I know how to create normal notifications like the blue bordered notifications in this image, but I want to show an icon and about 3 lines of information near that. How can I do that? Any suggestion will be appreciated.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Add RemoteViews in notification. Here is a sample:

enter image description here

var remoteViews = new RemoteViews(getPackageName(), R.layout.widget);
var mBuilder = new NotificationCompat.Builder(this)

// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, test.class);

// The stack builder object will contain an artificial back stack for
// the started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

// Adds the back stack for the Intent (but not the Intent itself)

// Adds the Intent that starts the Activity to the top of the stack

PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(, resultPendingIntent);

var notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

// mId allows you to update the notification later on.


<?xml version="1.0" encoding="UTF-8"?>
        android:text="DJ notification"
        android:textAppearance="?android:attr/textAppearanceMedium" />
        android:text="Close Me" />

check this article there is more style avaialbe

Android Developer


The NotificationCompat.Builder is the most easy way to create Notifications on all Android versions. You can even use features that are available with Android 4.1. If your app runs on devices with Android >=4.1 the new features will be used, if run on Android <4.1 the notification will be an simple old notification.

for < 11 API use

Method 2

Expanded notifications are available from Android 4.1 onwards to handle these scenarios. If you are using Notification.Builder or NotificationCompat.Builder, you would set up a normal Builder and a separate Builder for the expanded notification, using NotificationCompat.InboxStyle or one of the other styles, and connect the two.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment