Learn how to wire Jetpack ViewModel and LiveData together in an Android app without memory leaks or errors.
Use as a reference architecture for building an Android app with layered UI, ViewModel, and DataRepository structure.
Implement safe screen rotation handling and inter-screen messaging in an Android Jetpack project.
Requires Android Studio and a connected Android device or emulator to run the sample.
This is an Android sample application that demonstrates how to use Google's Jetpack MVVM architecture correctly and without common mistakes. The README is written in Chinese, and the project is aimed at Android developers who want a clear, working example of how Jetpack components fit together, rather than yet another article that pastes disconnected code snippets. Jetpack is a collection of Android libraries from Google covering things like ViewModel (which stores screen state across configuration changes), LiveData (which notifies the UI when data changes), Navigation (which manages screen transitions), and DataBinding (which connects layout files directly to data). The project shows how to wire these pieces together in a way that avoids memory leaks and unpredictable errors, particularly when switching between portrait and landscape layouts or when sending messages between different screens. The sample app takes the form of a music player, similar in appearance to Tencent's lighter music app. It demonstrates portrait-to-landscape layout switching with no unexpected errors, a unified event distribution system using LiveData and shared ViewModels, and a layered architecture where the UI layer talks to the ViewModel layer, which in turn talks to a DataRepository, with no reverse dependencies. The project avoids dependency injection tools like Dagger and explicitly states the goal is readable, maintainable code rather than clever tricks. The code is written entirely in Java and is licensed under the Apache License 2.0. According to a survey in the README, the architecture patterns shown here have been referenced or adopted by software teams at Tencent Music, NetEase Cloud Music, TCL, BMW, and several other companies. The app is available to download and try directly from app stores.
← kunminx on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.