Android Q — Bubbles

Android Q

Ah! Beta 2 version of Android Q is released with a set of new APIs. Among those, we will explore the Bubbles feature/API in this article.

So, What are Bubbles?

Bubbles are floating notifications on top of the other app content, and follow the user wherever they navigate. It can be expanded to provide more information and actions, also it can be collapsed when the action is done by the user.

Seems like you already familiar with this in Android?

Yes, you are right. It is like a facebook messenger’s chat head. As of today if you want to display a bubble(aka. chat head), you have to use android.permission.SYSTEM_ALERT_WINDOW, draw the bubble, handle touch, handle the move, etc…

Android Engineers simplified all these with this new Bubbles API.

How to add a Bubble?

Bubbles are built on top of the existing notification system to make it simpler. Simply create a new notification and add some meta information to show the Bubble. That’s it!

Android Q Bubbles
Bubble

The bubble will be displayed on top of the content on the screen.

On click of the bubble, an activity can be shown as a floating window.

Expanded Bubble

When the user clicks on the bubble, the intent associated with the BubbleMetaData will be shown to the user. This intent should be an activity intent.

The activity which acts as a floating window must be resizeable, embedded, and always launch in document UI mode. If it lacks any of these requirements it will display as a notification instead.

An activity can be configured as a pop-out screen via setContentIntent.

As Android Q is in Beta, there are multiple APIs still work in progress. As soon APIs are finalized, I will update the same page!

You can find the complete example here