I am trying to make a custom notification and it always ends up being pretty small (about the size of most notifications). I can see that Netflix and Youtube display much larger notifications which look custom (they might be big view) when casting to a chromecast device. How are they making them that large?
Thanks.
EDIT: Marked it as answered because of the comment pointing out bigContentView
A basic notification includes a title, some text, an icon, and a link. A title can contain up to 65 characters, a description is generally limited to 240 characters. However, some portions of these texts can be lost due to browser features.
Create custom layout for the content area DecoratedCustomViewStyle to your notification. This API allows you to provide a custom layout for the content area normally occupied by the title and text content, while still using system decorations for the notification icon, timestamp, sub-text, and action buttons.
High priority messages on Android are meant for time sensitive, user visible content, and should result in user-facing notifications. If FCM detects a pattern in which messages do not result in user-facing notifications, your messages may be deprioritized to normal priority.
You seem to already know... You're probably talking about big view style notifications. Google has specific training documentation as well as a technical guide for that. Here's some example code from there:
// Constructs the Builder object.
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_notification)
.setContentTitle(getString(R.string.notification))
.setContentText(getString(R.string.ping))
.setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission
/*
* Sets the big view "big text" style and supplies the
* text (the user's reminder message) that will be displayed
* in the detail area of the expanded notification.
* These calls are ignored by the support library for
* pre-4.1 devices.
*/
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.addAction (R.drawable.ic_stat_dismiss,
getString(R.string.dismiss), piDismiss)
.addAction (R.drawable.ic_stat_snooze,
getString(R.string.snooze), piSnooze);
Note the call to setStyle
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With