Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
How to Build Android Applications with Kotlin

You're reading from   How to Build Android Applications with Kotlin A hands-on guide to developing, testing, and publishing production-grade Android 16 apps

Arrow left icon
Product type Paperback
Published in Sep 2025
Publisher Packt
ISBN-13 9781835882764
Length 654 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Authors (4):
Arrow left icon
Alex Forrester Alex Forrester
Author Profile Icon Alex Forrester
Alex Forrester
Eran Boudjnah Eran Boudjnah
Author Profile Icon Eran Boudjnah
Eran Boudjnah
Alexandru Dumbravan Alexandru Dumbravan
Author Profile Icon Alexandru Dumbravan
Alexandru Dumbravan
Jomar Tigcal Jomar Tigcal
Author Profile Icon Jomar Tigcal
Jomar Tigcal
Arrow right icon
View More author details
Toc

Table of Contents (24) Chapters Close

Preface 1. Android Foundation
2. Creating Your First App FREE CHAPTER 3. Building User Screen Flows 4. Developing the UI with Jetpack Compose 5. Building App Navigation 6. App Components
7. Essential Libraries – Ktor, Kotlin Serialization, and Coil 8. Building Lists with Jetpack Compose 9. Android Permissions and Google Maps 10. Services, WorkManager, and Notifications 11. Code Structure
12. Testing with JUnit, Mockito, MockK, and Compose 13. Coroutines and Flow 14. Android Architecture Components 15. Persisting Data 16. Dependency Injection with Dagger, Hilt, and Koin 17. Polishing and Publishing an App
18. Architecture Patterns 19. Advanced Jetpack Compose 20. Launching Your App on Google Play 21. Unlock Your Book’s Exclusive Benefits 22. Other Books You May Enjoy 23. Index

Exploring ViewModel

The ViewModel component is responsible for holding and processing data required by the UI. It has the benefit of surviving configuration changes that destroy and recreate fragments and activities, which allows it to retain the data that can then be used to re-populate the UI.

ViewModel components will eventually be destroyed when the activity or fragment is destroyed without being recreated or when the application process is terminated. This allows ViewModel to serve its responsibility and be garbage collected when it is no longer necessary. The only method ViewModel has is onCleared(), which is called when ViewModel terminates. You can use this method to terminate ongoing tasks and deallocate resources that will no longer be required.

Migrating data processing from activities into ViewModel helps create better and faster unit tests. Testing an activity requires an Android test to be executed on a device. Activities also have states, which means that your...

lock icon The rest of the chapter is locked
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
How to Build Android Applications with Kotlin
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon