Fragments: The good (non-deprecated) parts
summary
Fragments now give concrete pieces: use AndroidX lifecycle with repeatOnLifecycle to auto-start/stop work in ViewPager pages, put long‑lived state into ViewModels (fragment or parent scope), pass results with the fragment result APIs mediated by FragmentManager, and test with FragmentScenario plus injected FragmentFactory and fake ActivityResultRegistry via registerForActivityResult. Replace action bar coupling with the MenuHost + MenuProvider pattern, and detect deprecated usage at runtime with FragmentStrictMode instead of relying on fragment-only APIs.
AI-written summary · about
chapters (8)
- 0:00The evolution of fragments
- 1:01Modern fragment architecture
- 2:05Lifecycle and state management
- 4:04ViewModels in fragments
- 6:15Result and testability APIs
- 8:45Dependency injection and testing
- 12:22Menu and app bar integration
- 15:20Fragment strict mode
related talks
30mFragments: What are they good for.
46mAndroid Jetpack: How to smartly use fragments in your UI
37mWhat To Do About Fragments? (en)
56mYou've been told lies about Fragments
33mFear No Fragments
46mModern Android: How to ditch Activities and Fragments
31mFragments — As Incredible as It Seems
39mACTIVITIES AND FRAGMENTS ARE NOT MVX VIEWS
