Understand the android-activity architecture and state management
mainUnlike older Android glue crates, android-activity is designed to avoid global static state. This provides several architectural benefits:
- Encapsulated State: Instead of using global getters to access application state, the entry point provides an explicit
app: AndroidAppargument. This argument encapsulates the state connected to a singleActivity. - Lifecycle Resilience: Because it avoids global statics, applications can gracefully handle repeated
create -> run -> destroycycles of theActivity. - Multi-Activity Support: The design theoretically allows for running multiple
Activityinstances simultaneously, as state is not tied to a global singleton. - Thread Synchronization: The crate encapsulates the Inter-Process Communication (IPC) and synchronization required between the native thread and the JVM thread, reducing the risk of race conditions during state changes (like state saving).