CodeName OneShai Almog5 min readintermediate
App Intents: One Java Declaration for Siri, Spotlight, and Shortcuts
Summary
Codename One adds @AppIntent annotations that let a static Java method be exposed as a Siri, Spotlight, or Android shortcut. The build‑time processor generates native declarations, a reflection‑free dispatch table, and validates the intent metadata. Handlers can be headless, accept typed parameters, return results, and be invoked internally via Intents.invoke(). Entities enable system‑driven disa…
- Static @AppIntent methods are compiled into native intent declarations for iOS (App Intents, Spotlight) and Android launcher shortcuts; no runtime reflection is used.
- The Maven bytecode processor validates phrases, entities, and routes at build time, preventing silent failures.
- Headless handlers run without a UI thread, can use storage/networking, but must respect a platform‑enforced timeout and cooperative cancellation.
- Entity classes expose @EntityId, @EntityTitle, and @EntityQuery methods so the OS can search and let users pick an object before the handler runs.
Cross‑platform mobile apps often need to expose functionality to OS‑level services (Siri, Spotlight, Android shortcuts). Codename One’s annotation‑driven approach eliminates duplicated native code, ensures compile‑time safety, and lets the same Java logic serve as a voice command, search result, or…
6/10