I am trying to build custom notification for my app, but I am not able to remove the header information (which includes small icon, app name, time) and the expand icon. Basically I want completely my own design of notification which takes full width and height.
private void createNotification() {
// BEGIN_INCLUDE(notificationCompat)
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL);
Intent i = new Intent(this, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(this, 0, i,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(intent);
builder.setSmallIcon(R.drawable.ic_stat_custom);
builder.setAutoCancel(true);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);
// Set text on a TextView in the RemoteViews programmatically.
final String time = DateFormat.getTimeInstance().format(new Date()).toString();
final String text = getResources().getString(R.string.collapsed, time);
contentView.setTextViewText(R.id.textView, text);
builder.setCustomContentView(contentView);
if (Build.VERSION.SDK_INT >= 16) {
// Inflate and set the layout for the expanded notification view
RemoteViews expandedView =
new RemoteViews(getPackageName(), R.layout.notification_expanded);
builder.setCustomBigContentView(expandedView);
}
Notification notification = builder.build();
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(0, notification);
}
I am getting this as output:
But I want this notification as:
Is there anyway to achieve this?
u can easily add
.setSmallIcon(android.R.color.transparent)
or create custom notification, check this doc out: https://developer.android.com/develop/ui/views/notifications/custom-notification
also this is an article about custom notification:
https://medium.com/hootsuite-engineering/custom-notifications-for-android-ac10ca67a08c
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.