MikhbarMIKHBAR
Mobile

Android Developers Introduce Remote Compose Alpha for Widgets

Android Developers have introduced Remote Compose, a new alpha library designed to help developers build interactive gaming widgets with advanced animations and efficient local state handling.

Android Developers Introduce Remote Compose Alpha for Widgets

Introduction to Remote Compose

Android Developers have launched a blog post series exploring how to build interactive Android gaming widgets utilizing a new alpha library named <a href="https://developer.android.com/blog/posts/remote-compose-gaming-widgets">Remote Compose</a>. While Jetpack Glance remains the recommended choice for most widgets due to its backwards compatibility and simplified tooling, certain use cases involving animations require alternative solutions.

For standard implementations, developers typically rely on <a href="https://developer.android.com/develop/ui/compose/glance">Jetpack Glance</a>. However, the legacy RemoteViews system it depends on lacks support for mathematical expressions and is restricted by Android system limits on widget update frequency and size.

Android Developers Introduce Remote Compose Alpha for Widgets
Image related to the report from Android Developers · Source: Android Developers

Internal Gaming Widgets and Architecture

To demonstrate practical applications of the new library, the blog series showcases two internal gaming widgets: Android Pet, a customizable virtual pet that evolves, and Flappy Droid, a side-scrolling game where users navigate columns. The architecture separates UI definitions from execution by running declarative code to serialize layouts into compact Remote Documents.

These documents are sent to a host process, such as the home screen launcher, where a Remote Compose player manages local interactions, resizing, state changes, and animations. This mechanism operates similarly to a web browser rendering an HTML document.

simpleWidget.png
A simple Remote Compose widget, ready to animate. · Source: Android Developers

Efficiency and Process Independence

Because the player manages updates independently within its own process, the main application process does not need to stay awake. This approach reduces Inter-Process Communication round-trips, thereby lowering latency and minimizing battery drain compared to traditional RemoteViews-based widgets.

Remote Documents typically measure only a few dozen kilobytes. Once the launcher receives the document, the host application is free to suspend while the widget remains fully interactive for the user.

Android Developers Introduce Remote Compose Alpha for Widgets
Image related to the report from Android Developers · Source: Android Developers

Building Basic Widgets and Dependencies

Creating a basic Remote Compose widget follows steps similar to configuring a standard <a href="https://developer.android.com/develop/ui/views/appwidgets">AppWidget</a>, but incorporates Remote Composables for the user interface. Developers must add the required <a href="https://developer.android.com/jetpack/androidx/releases/compose-remote">Remote Compose dependencies</a> to their version catalog and build configuration.

Additionally, developers register their receiver in the Android manifest and include the appropriate intent filter. The widget class inherits from RemoteComposeWidget, compiling layout and drawing commands into a serialized binary document sent via updateRemoteView.

Remote Compose Gaming Widgets
Image related to the report from Android Developers · Source: Android Developers

State Management Options

When building these widgets, developers can handle state using two distinct approaches. Host-local state suits ephemeral session data—such as a game score in Flappy Droid—that can reset if the launcher restarts or a new document is emitted.

Conversely, app-side persistence is required when state must survive across document updates, as demonstrated by Android Pet, where users collect gold coins in the widget to spend within the main application store.

Sources

Continue chronologically

Related entity coverage