Exploring Android Q: Including bubble notifications to your app

In 2018, Google added a brand new “chat head” characteristic to its iPhone software, which displayed the caller’s avatar as a floating bubble-style notification. When tapped, this bubble expanded to disclose a strip of controls that allowed the consumer to carry out duties straight from the notification, together with placing the caller on speaker telephone and hanging up.

In Android Q, Google is making “chat head” notifications an official a part of the Android platform, with the introduction of the Bubble API. These bubbles can comprise helpful details about occasions which can be occurring elsewhere in your app, however they’ll additionally comprise customized actions. These actions permit the consumer to work together together with your app, even after they’re viewing one other Exercise, software, or they’re positioned in an unrelated a part of the Android working system.

On this article, I’ll share every part it’s essential learn about this upcoming Android Q characteristic, together with what bubbles have to supply the developer and the end-user, greatest practices, and a few limitations you want to concentrate on, earlier than you begin utilizing bubbles in your personal Android apps.

By the top of this text, you’ll be on top of things with this new Android Q characteristic, and could have created an Android app that options its personal bubble notifications.

What are Android Q’s bubbles?

Bubbles show your app’s content material in a window that seems to “float” above the prevailing foreground Exercise.

In its collapsed state, a bubble notification is represented by a small icon. These icons are plain white by default, however you may customise them with a picture, for instance you would possibly use your app’s icon, or the avatar of the one that’s related to this notification.

Bubble notifications appear as collapsed icons in their default state

When the consumer faucets a collapsed bubble, an intent shall be invoked and your bubble shall be displayed in its expanded state, which usually accommodates further info and may present entry to some associated performance.

Clicking a bubble icon will reveal its expanded layout

When a bubble is expanded, the related software turns into the foreground course of, if it isn’t already.

Customers can work together with a bubble with out having to navigate away from their present Exercise, which makes bubbles a strong strategy to re-engage customers, and probably draw them again to your app.

Even when the consumer is already inside your app, a bubble will help them shortly and simply reply to necessary occasions which can be occurring elsewhere in your software. For instance, think about you’ve developed a messaging app, and the consumer receives a message from Contact B, after they’re halfway by drafting a message to Contact A. Moderately than forcing them to navigate to the Exercise the place this occasion occurred, you may current Contact B’s message as a bubble notification, and the consumer can then learn and reply to that message with out having to navigate away from their draft.

Except the consumer explicitly dismisses a bubble by dragging it offscreen, that bubble will stay seen even when the consumer navigates between completely different purposes and areas of the working system. Since bubbles are a persistent a part of the Android consumer interface (UI), they’ll present a handy place to retailer notes or handle ongoing duties, for instance you would possibly retailer the consumer’s To Do record or journey itinerary inside a bubble, so it’s at all times inside simple attain.

You might even use bubbles as reminders, for instance your app would possibly generate a bubble when it’s time for the consumer to log into a gathering, ship an necessary e-mail, or carry out another time-sensitive process.

Haven’t Fb been utilizing bubble notifications for years?

Floating bubble-style notifications aren’t a brand new idea for Android, as they’ve lengthy been out there in third social gathering apps, most notably in Fb Messenger. Nevertheless, beforehand it was the developer’s accountability to design and implement their very own bubble notifications.

Making a customized characteristic is at all times extra time-consuming than leveraging lessons and APIs which can be already constructed into the Android platform, so now that bubbles are formally a part of Android it ought to be a lot simpler for builders to make use of this notification fashion. This official assist will even present a extra constant expertise for customers, as all bubbles ought to now have precisely the identical behaviour, whatever the software that generated them.

Android Q bubbles: What are the restrictions?

Bubbles are displayed on high of no matter content material the consumer is at the moment viewing. In case your app generates numerous bubbles, or it creates pointless bubble notifications, then customers are shortly going to lose persistence together with your app.

Somebody who feels bombarded by bubbles might select to disable the bubble characteristic in your software, or they might even uninstall your app solely.

To safeguard the consumer expertise, your bubble notifications will solely be displayed in the event that they meet at the least one of many following standards:

Your software is within the foreground when the notification is shipped.The notification has a Particular person added. If there are a number of folks related to a notification, then it’s essential to additionally mark this dialog as a bunch, utilizing setGroupConversation(boolean).The notification is from a name to Service.startForeground, has a Particular person added, and falls into the CATEGORY_CALL notification class, which signifies it is a synchronous communication request, akin to a voice or video name.

If none of those situations are met, then your bubbles shall be displayed as an ordinary notification as an alternative. If the machine is locked or its always-on show is energetic, then your bubbles will once more solely seem as commonplace notifications.

You also needs to remember that on the time of writing, bubbles have been an non-obligatory characteristic. When your software first tries to generate a bubble, the consumer shall be introduced with a permissions dialog they usually’ll have the choice to disable bubbles in your software. If the consumer disables the bubble characteristic, then your app’s bubbles will at all times be displayed as commonplace notifications, even when they fulfil all the above standards.

What we’ll be creating

On this article, we’ll construct an software that makes use of Android Q’s new bubble notifications characteristic. To make our app simpler to check, it’ll characteristic a button that generates a bubble notification each time its tapped.

We'll be creating an app that triggers a bubble notification on-demand

Since chat purposes are the obvious alternative for bubbles, our app will simulate the consumer receiving a brand new message, much like the Fb Messenger app. When expanded, this bubble will embody an area the place the message could be displayed, plus two actions that the consumer can carry out: name this contact, or ship them a textual content response.

Android Q's bubble notifications can contain information and actions

To experiment with this new characteristic, you’ll want the most recent preview of Android Studio three.5. You’ll discover the most recent model over on the Preview Launch web site.

You’ll additionally want the Android Q preview SDK and Android SDK Construct-Instruments 28, or larger:

Choose “Instruments > SDK Supervisor” from the Android Studio toolbar.Within the subsequent window, choose the “SDK Platforms” tab.Choose the most recent launch of “Android Q Preview.”Swap to the “SDK Instruments” tab.Choose “Android SDK Construct-Instruments 28,” or larger.Click on “OK” to put in these parts.

Notice that the next tutorial was created utilizing Android Q Beta 2, when bubble notifications have been nonetheless thought of an experimental characteristic. When you’re utilizing a later model of Android Q, then it’s possible you’ll encounter some minor variations.

Constructing our Android Q app

To get began, create a brand new Android undertaking utilizing the “Empty Exercise” template, and when prompted ensure that your app is focusing on the most recent model of Android Q.

When you’re including bubbles to an present software, you then’ll have to open your undertaking’s construct.gradle file and improve compileSdkVersion, minSdkVersion and targetSdkVersion to “android-Q.”

compileSdkVersion ‘android-Q’

Subsequent, open your construct.gradle file and add the most recent model of the Materials Parts for Android library to your “dependencies” block:

implementation fileTree(dir: ‘libs’, embody: [‘*.jar’])
implementation ‘androidx.appcompat:appcompat:1.Zero.2’
implementation ‘androidx.constraintlayout:constraintlayout:1.1.three’

//Add the next//

implementation ‘’
testImplementation ‘junit:junit:four.12’
androidTestImplementation ‘androidx.check.ext:junit:1.1.Zero’
androidTestImplementation ‘androidx.check.espresso:espresso-core:three.1.1’

Creating the primary consumer interface

Our undertaking will finally want two layouts: one for the primary software, and one which defines the structure of our expanded bubble.

Open your undertaking’s activity_main.xml file, and let’s create the button that’ll generate our bubble notification:

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *