File: MyApp.kt
Module: core
Purpose: Android Application entry point. Initializes global services (logging, DI, network observers), exposes app‑wide context, and configures core defaults.
| Component / Resource |
Type |
ID / Key |
Purpose |
MyApp |
Application |
– |
Process-level bootstrap for the app |
appContext |
Context |
– |
Safe accessor for global context |
Logging |
Utility |
– |
Initializes core logging pipeline |
NetworkStatusObserver |
Singleton |
– |
Observes device connectivity for the app |
- Initializes Logging with build-type aware configuration.
- Creates and registers NetworkStatusObserver.
- Exposes
appContext via companion for utilities that need a context without leaking activities.
- Guards double‑init with idempotent flags.
| Method / Property |
Purpose |
onCreate() |
Bootstraps logging, network observer, and any DI hooks. |
companion object appContext |
Provides global Context once MyApp is created. |
| Test Case |
Description |
testOnCreateIsIdempotent() |
Calling init twice does not re-register observers or crash. |
testAppContextNonNull() |
appContext returns non-null after onCreate. |
| Scenario |
Description |
| Process start |
App launches; logs show “Core init ok”; network observer active. |
| Background / foreground |
Observer remains registered across activity swaps. |
- Hook DI (Koin/Hilt) when ready.
- Add crash reporting toggled by build type.
- Lazy‑init heavy subsystems on demand.