Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Use this code:
private fun Context.createNotificationChannel() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val name = "Testing"
val descriptionText = "Testing"
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel("Testing", name, importance).apply {
description = descriptionText
}
// Register the channel with the system
val notificationManager: NotificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
}
}
fun Context.notification() {
createNotificationChannel()
val notification = NotificationCompat.Builder(this, "Testing")
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle("Small Title")
.setContentText("This is a smaller text that should show up if the notification is not expanded")
.setSubText("Small Summary")
.setStyle(NotificationCompat.BigTextStyle()
.bigText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.setBigContentTitle("Big Title")
.setSummaryText("Big Summary")
)
.build()
with(NotificationManagerCompat.from(this)) {
// notificationId is a unique int for each notification that you must define
notify(123, notification)
}
}
- What happened.
On Android 10 the Notification was created but the text in bigText always shows regardless if the notification is expanded or not. setBigContentTitle's content shows when the notification is expanded only.
On lower android versions it behaves correctly.
- What you think the correct behavior should be.
When the notification is not expanded, the text set by setContentText should be displayed. This is not happening on Android 10. On lower android versions it behaves correctly.
This was tested on a Pixel 2 with Android 10 and build number QP1A.190711.020