Modern Android 13 Development Cookbook

Book description

Save months of trial and error with concise guided recipes in this part-color guide and build exceptional Android applications and wearables and support the new foldable technology by using the latest Jetpack libraries

Key Features

  • Leverage the power of the latest Jetpack libraries in your day-to-day Android development tasks
  • Explore Wear OS and build large screens to support the foldable world using the declarative approach
  • Write tests and debug your code as you discover the most useful tips, tricks, and best practices
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

Android is a powerful operating system widely used in various devices, phones, TVs, wearables, automobiles, and more. This Android cookbook will teach you how to leverage the latest Android development technologies for creating incredible applications while making effective use of popular Jetpack libraries. You’ll also learn which critical principles to consider when developing Android apps.

The book begins with recipes to get you started with the declarative UI framework, Jetpack Compose, and help you with handling UI states, Navigation, Hilt, Room, Wear OS, and more as you learn what's new in modern Android development. Subsequent chapters will focus on developing apps for large screens, leveraging Jetpack’s WorkManager, managing graphic user interface alerts, and tips and tricks within Android studio. Throughout the book, you'll also see testing being implemented for enhancing Android development, and gain insights into harnessing the integrated development environment of Android studio. Finally, you’ll discover best practices for robust modern app development.

By the end of this book, you’ll be able to build an Android application using the Kotlin programming language and the newest modern Android development technologies, resulting in highly efficient applications.

What you will learn

  • Use Kotlin programming to build your Android applications
  • Leverage modern Android development (MAD) libraries to create exceptional apps
  • Explore modern app architecture concepts such as model-view-viewmodel (MVVM)
  • Utilize dependency injection, clean architecture, and module organization
  • Discover how to write UI and unit tests for your applications
  • Get to grips with paging, data binding, and datastore
  • Build large screens to support the new foldable world
  • Explore principles of Wear OS in modern Android development

Who this book is for

This book is for active junior-to-mid-level Android developers with one to two years of professional experience in developing Android applications who are interested in advancing their knowledge of Android development. The recipes in this book use Kotlin and not Java.

Table of contents

  1. Modern Android 13 Development Cookbook
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
    9. Download a free PDF copy of this book
  6. Chapter 1: Getting Started with Modern Android Development Skills
    1. Technical requirements
    2. Writing your first program in Kotlin using variables and idioms
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    3. Creating a Hello, Android Community app using Android Studio
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Setting up your emulator in Android Studio
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Creating a button in Jetpack Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Utilizing gradlew commands to clean and run your project in Android Studio
      1. Getting ready
      2. How to do it…
      3. How it works
      4. See also
    7. Understanding the Android project structure
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Debugging and logging in Android Studio
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
  7. Chapter 2: Creating Screens Using a Declarative UI and Exploring Compose Principles
    1. Technical requirements
    2. Implementing Android views in Jetpack Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Implementing a scrollable list in Jetpack Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    4. Implementing your first tab layout with a view pager using Jetpack Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Implementing animations in Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Implementing accessibility in Jetpack Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Implementing declarative graphics using Jetpack Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  8. Chapter 3: Handling the UI State in Jetpack Compose and Using Hilt
    1. Technical requirements
    2. Implementing DI with Jetpack Hilt
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Implementing ViewModel classes and understanding the state in Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also…
    4. Implementing Compose in an existing XML layout-based project
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Understanding and handling recomposition in Jetpack Compose
      1. How to do it…
      2. How it works…
      3. See also
    6. Writing UI tests for your Compose views
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Writing tests for your ViewModels
      1. Getting ready
      2. How to do it…
      3. How it works…
  9. Chapter 4: Navigation in Modern Android Development
    1. Technical requirements
    2. Implementing a bottom navigation bar using navigation destinations
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Navigating to a new screen in Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    4. Navigating with arguments
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Creating deep links for destinations
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Writing tests for navigation
      1. Getting ready
      2. How to do it…
      3. How it works…
  10. Chapter 5: Using DataStore to Store Data and Testing
    1. Technical requirements
    2. Implementing DataStore
      1. How to do it…
      2. How it works…
    3. Adding Dependency Injection to DataStore
      1. How to do it…
      2. How it works…
      3. There’s more…
      4. See also
    4. Using Android Proto DataStore versus DataStore
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    5. Handling data migration with DataStore
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Writing tests for our DataStore instance
      1. How to do it…
      2. How it works…
      3. See also
  11. Chapter 6: Using the Room Database and Testing
    1. Technical requirements
    2. Implementing Room in your applications
      1. How to do it…
      2. How it works…
    3. Implementing Dependency Injection in Room
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    4. Supporting multiple entities in Room
      1. Getting ready
      2. How to do it …
      3. How it works…
      4. There’s more...
    5. Migrating an existing SQL database to room
      1. How to do it…
      2. How it works…
    6. Testing your local database
      1. Getting ready
      2. How to do it…
      3. How it works…
  12. Chapter 7: Getting Started with WorkManager
    1. Technical requirements
    2. Understanding the Jetpack WorkManager library
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Understanding WorkManager state
      1. How to do it…
      2. How it works…
    4. Understanding threading in WorkManager
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    5. Understanding chaining and canceling work requests
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    6. Implementing migration from Firebase JobDispatcher to the new recommended WorkManager
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. How to debug WorkManager
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Testing Worker implementations
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  13. Chapter 8: Getting Started with Paging
    1. Technical requirements
    2. Implementing the Jetpack Paging library
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Managing present and loading states
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Implementing your custom pagination in Jetpack Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Loading and displaying paged data
      1. How to do it…
      2. How it works…
    6. Understanding how to transform data streams
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    7. Migrating to Paging 3 and understanding the benefits
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Writing tests for your Paging Source
      1. Getting ready
      2. How to do it…
      3. How it works…
  14. Chapter 9: Building for Large Screens
    1. Technical requirements
    2. Building adaptive layouts in Modern Android Development
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Building adaptive layouts using ConstraintLayouts
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Handling large-screen configuration changes and continuity
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Understanding activity embedding
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Material Theming in Compose
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also…
    7. Testing your applications on a foldable device
      1. Getting ready
      2. How to do it…
      3. How it works…
  15. Chapter 10: Implementing Your First Wear OS Using Jetpack Compose
    1. Technical requirements
    2. Getting started with your first Wear OS in Android Studio
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Creating your first button
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Implementing a scrollable list
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Implementing Cards in Wear OS (TitleCard and AppCard)
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Implementing a chip and a toggle chip
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Implementing ScalingLazyColumn to showcase your content
      1. Getting ready
      2. How to do it…
      3. How it works…
  16. Chapter 11: GUI Alerts – What’s New in Menus, Dialog, Toast, Snackbars, and More in Modern Android Development
    1. Technical requirements
    2. Creating and displaying a menu in Modern Android Development
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Implementing a Toast/Snackbar to alert users
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Creating an alert dialog
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Creating a bottom sheet dialog
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There is more…
    6. Creating a radio button
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Creating a FAB/extended FAB
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There more …
  17. Chapter 12: Android Studio Tips and Tricks to Help You during Development
    1. Technical requirements
    2. The importance of profiling your Android applications
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See more…
    3. Quick Android shortcuts to make your development faster
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. JetBrains Toolbox and essential plugins to know
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Debugging your code
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. How to extract methods and method parameters
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Understanding Git essentials
      1. Getting ready
      2. How to do it…
      3. How it works…
  18. Index
    1. Why subscribe?
  19. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Modern Android 13 Development Cookbook
  • Author(s): Madona S. Wambua
  • Release date: July 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781803235578