Skip to main content

Codename One Introduces Single Java API for Widgets, Live Activities, and Dynamic Island

Java and Kotlin developers can now build home-screen widgets and Live Activities using PR #5365 and the com.codename1.surfaces component.

AI-written
Inewgen
26 Jul 2026Source: Dev.to3 min read (0 views)Last updated 04 Aug 2026
Share
Codename One Introduces Single Java API for Widgets, Live Activities, and Dynamic Island

Stock photo for illustration only, not from the actual event

Font size
  • Codename One adds the com.codename1.surfaces package for home-screen widgets.
  • Supports iOS, Android, desktop, and web from a single codebase.
  • Utilizes data and timeline models instead of running live UI components.
  • Push-driven widget updates are not included in this initial release.

Widget support ranked among the earliest feature requests for Codename One. The team dismissed it for years because a widget must render while the application user interface is not running. A standard Codename One component requires the application renderer, event dispatch thread, and a live object graph, none of which are available to a home-screen widget.

For those unfamiliar with the framework, Codename One is an open-source platform enabling developers to build native iOS, Android, desktop, and web applications using a single Java or Kotlin codebase. The missing piece had been hiding in plain sight for a decade after Steve introduced background processes, allowing an app to refresh data without showing its UI. This solved the update side, while the rendering side became feasible once a widget was treated as data rather than a live component.

smartphone interface widgets user interface design

Stock photo for illustration only, not from the actual event

Pull Request #5365 translates that observation into com.codename1.surfaces, a unified API for home-screen widgets, Live Activities, Dynamic Island, Android ongoing notifications, and desktop floating widgets. An application publishes a serializable layout alongside a timeline of state maps, allowing the operating system to persist that data and render it using its native surface technology.

Transforming UI components into serializable layouts and timelines rather than executing live objects is a crucial architectural pattern for cross-platform frameworks. It bridges the gap with modern mobile operating systems like iOS and Android, which restrict external background processes from executing real-time custom UI rendering loops directly on the home screen.

Never miss the latest news?

Subscribe to get news summaries by email - not often enough to be annoying.

โฆษณา

Developers cannot attach a Java listener directly to a widget since a Java process might not be running to invoke it. Instead, apps assign a string action ID; tapping the widget launches the application and delivers that action post-startup. Furthermore, the simulator implements this exact model, allowing developers to inspect registered kinds, navigate timelines, modify sizes, and test actions via Widgets > Widgets Preview without needing a device build.

Both iOS and Android compile widget galleries directly into the native application, requiring kinds to be defined at build time by adding a surfaces.json resource file:

  • Register widget kinds such as delivery_status
  • Set display names like Delivery and descriptions like Track your order
  • Support widget sizes including SMALL and MEDIUM

Referencing the surfaces package acts as a build gate, ensuring apps that never utilize it receive no WidgetKit extension, Android receiver, app group, or surface resources. Push-driven widget updates are omitted from this version, meaning apps publish timelines and background fetch republishes them, while live activities accept app-driven updates. Server-pushed state and ActivityKit push tokens remain planned atop the same wire format.

Source: Dev.to

Comments

Leave a Comment
0/2000

Found something wrong in this article? Report an issue with this article