
How to implement Android bubble notification in Android Studio
To set up properly implement bubble notifications in the Android App, Bubble notifications require Android 10 (API 29) or higher, follow these steps
Set Up PendingIntent for bubble notification
Intent intent = new Intent(context, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
context, 0, intent ,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE
);Set Up BubbleMetadata for bubble notification
NotificationCompat.BubbleMetadata bubbleMetadata =
new NotificationCompat.BubbleMetadata.Builder()
.setDesiredHeight(600) // Set the desired bubble height
.setIcon(IconCompat.createWithResource(context, R.drawable.img_circle_logo)) // Bubble icon
.setIntent(pendingIntent ) // Intent for bubble content
.build();Create the notification builder for bubble notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, String.valueOf(unique_id))
.setSmallIcon(R.drawable.img_circle_logo)
.setBubbleMetadata(bubbleMetadata) // Set BubbleMetadata
.setContentTitle(title)
.setContentText(msg)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_MESSAGE) // Recommended for chat bubbles
.setAutoCancel(true);
Display the Notification
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify("unique_id", builder.build());Important Note for Bubble Notification
If you are not set to SDK version checking for a notification channel, you should create a notification channel for API 26+, It’s an important part, so ensure to add this code into your class.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(
"my_channel_id",
"Bubble Channel",
NotificationManager.IMPORTANCE_HIGH
);
NotificationManager manager = context.getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
}Verify Bubble Permissions
For some devices, users may need to enable bubble notifications manually from settings. If you do this setup, bubble notifications will show properly.






