How to make a custom notification the like a picture attachment.enter image description here Do you have any suggest or idea for it?
Asked
Active
Viewed 398 times
-2
-
1Possible duplicate of [Push Notifications in Android Platform](https://stackoverflow.com/questions/1378671/push-notifications-in-android-platform) – emsimpson92 Jun 20 '18 at 16:42
1 Answers
0
You can use RemoteViews
for this
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.YOUR_CUSTOM_LAYOUT);
contentView.setImageViewResource(R.id.YOUR_IMAGEVIEW_ID, YOUR_ICON);
contentView.setTextViewText(R.id.YOUR_TEXT_VIEW_ID, YOUR_NOTIFICAITON_TEXT);
You can add more parameters and customize it more, you have to read the RemoveViews
documentation.
Then you create a NotificationCompat.Builder
and add contentView
as a content
from NotificationCompat.Builder
something like this :
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(YOUR_CONTEXT)
.setContent(contentView);
Then create the Notification
Notification mNotification = mBuilder.build();
mNotificationManager.notify(1, mNotification);
Those are the simple steps, now you can adjust it to your liking.

Skizo-ozᴉʞS ツ
- 19,464
- 18
- 81
- 148