Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Michael Fazio

Rating No ratings yet

Start building native Android apps the modern way in Kotlin with Jetpack's expansive set of tools, libraries, and best practices. Learn how to create efficient, resilient views with Fragments and share data between the views with ViewModels. Use Room to persist valuable data quickly, and avoid NullPointerExceptions and Java's verbose expressions with Kotlin. You can even handle asynchronous web service calls elegantly with Kotlin coroutines. Achieve all of this and much more while building two full-featured apps, following detailed, step-by-step instructions.With Kotlin and Jetpack, Android development is now smoother and more enjoyable than ever before. Dive right in by developing two complete Android apps. With the first app, Penny Drop, you create a full game complete with random die rolls, customizable rules, and AI opponents. Build lightweight Fragment views with data binding, quickly and safely update data with ViewModel classes, and handle all app navigation in a single location. Use Kotlin with Android-specific Kotlin extensions to efficiently write null-safe code without all the normal boilerplate required for pre-Jetpack + Kotlin apps. Persist and retrieve data as full objects with the Room library, then display that data with ViewModels and list records in a RecyclerView. Next, you create the official app for the Android Baseball League. It's a fake league but a real app, where you use what you learn in Penny Drop and build up from there. Navigate all over the app via a Navigation Drawer, including specific locations via Android App Links. Handle asynchronous and web service calls with Kotlin Coroutines, display that data smoothly with the Paging library, and send notifications to a user's phone from your app. Come build Android apps the modern way with Kotlin and Jetpack! What You Need: You'll need the Android SDK, a text editor, and either a real Android device or emulator for testing. While not strictly required, it's assumed you're using Androi

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on guide to building modern native Android apps in Kotlin using Jetpack, taught through two complete projects rather than isolated snippets. Best for developers with some programming background who want a practical, project-driven path into Fragments, ViewModels, Room, coroutines, and navigation. 【Book Arc】 - **Opening (~0%–10%)**: Sets up the toolchain and project foundation — Android SDK, emulator/device, API level choices, AndroidX, and the first Fragments with data binding and a navigation graph. - **Early (~10%–35%)**: Builds the Penny Drop game's UI and logic: layouts, Kotlin null-safety and expressions, ViewModel/LiveData wiring, AI player classes, and game rules. - **Middle (~35%–55%)**: Adds persistence and data flow — Room database, DAO classes, type converters, repositories, and displaying records in a RecyclerView. - **Late (~55%–80%)**: Moves to the second app (Android Baseball League), reusing earlier patterns while introducing a Navigation Drawer, App Links, and deeper architecture. - **Ending (~80%–100%)**: Handles asynchronous web service calls with coroutines, smooths list display with the Paging library, and adds user notifications. 【Key Takeaways】 - **Kotlin removes Java's boilerplate and null hazards** (Early): null-safe code, expression-based `if…else` (no ternary), and first-class functions make Android code shorter and safer. - **Fragments plus ViewModels are the core view architecture** (Early): lightweight Fragment views with data binding, backed by lifecycle-aware ViewModels and LiveData, keep UI and state cleanly separated. - **Navigation belongs in one place** (Opening–Early): a navigation graph and menu file centralize which Fragment displays and which bottom-nav item is selected. - **Room persists real objects, not just primitives** (Middle): DAOs with `@Query`, `@Insert`, and `@Update` handle most work, while `@TypeConverter` functions bridge custom types like AI, dates, and lists. - **Repositories combine multiple data sources** (Middle): merging database LiveData with status data through a single update function avoids duplicated logic. - **Coroutines make async work readable** (Late): `suspend` functions and `viewModelScope.launch` handle web calls and AI turns without callback nesting. - **Two apps reinforce the same patterns** (Middle–Ending): Penny Drop teaches fundamentals; the Baseball League app layers navigation, paging, and notifications on top. - **Paging and notifications complete the production picture** (Ending): the Paging library keeps long lists smooth, and app-driven notifications reach the user's phone. 【Reading Tips】 - **Build along, don't just read**: the book is step-by-step, so typing the code and running each stage is where the learning happens. - **Deep-read the ViewModel/LiveData and Room chapters**: these are the architectural backbone reused in both apps; skimming them will make later chapters confusing. - **Skim configuration and setup details** (API levels, Gradle dependencies) on a first pass, then return when you hit a build error. - **Watch the Kotlin-specific asides** (no ternary, expression blocks, first-class functions) — they explain why the code looks different from Java Android tutorials. - **Treat the second app as review plus extension**: use it to confirm patterns and focus on what's new (Navigation Drawer, App Links, coroutines, Paging). 【Coverage Limits】 This guide is synthesized from stratified excerpts covering the book's opening through late stages; specific chapter titles, exact percentages, and some ending details are not fully represented in the excerpts.
Excerpt 1
the modern way with Kotlin and Jetpack! What You Need: You'll need the Android SDK, a text editor, and either a real Android device or emulator for testing....
View in text
Excerpt 2
the <LinearLayout>, with each button getting three of those “sections.” In practice, this means both buttons are the same size and the OR in the middle gets...
View in text
Excerpt 3
ameHandler, then we’ll have a fully working game. Let’s get a quick overview of what’s going to happen in here: we’ll add/remove the current player’s pennies...
View in text
Excerpt 4
val slots = slots.value if (game != n ull && players != n ull && currentPlayer != n ull && slots != n ull GameHandler .playAITurn(players, currentPlayer, slo...
View in text
Excerpt 5
to fragment_game.xml to use the new color state list files. While we’re in there, let’s also update the android:drawableTint and android:textColor attributes...
View in text
Excerpt 6
o the Repository and DAO classes. Add the BaseballDao Class As a reminder, the DAO is either an interface or abstract class that will pull data in from our R...
View in text
Excerpt 7
Flow<PagingData< PlayerListItem>> { Summary and Next Steps Our Players screen is complete and fully integrated with the Paging library. We’re able to continu...
View in text
Excerpt 8
ases, a simple text link is all that someone would want and will handle what you need. What’s next? For the ABL app, nothing, at least not in this book. We’v...
View in text
Tags
AI categories
Programming LanguageMobileSoftware
ISBN: 1680507605
Publisher: Pragmatic Bookshelf
Publish Year: 2021
Language: English
Pages: 570
File Format: PDF
File Size: 10.3 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…