Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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
Thriving in Android Development Using Kotlin
Thriving in Android Development Using Kotlin

Thriving in Android Development Using Kotlin : A project-based guide to using the latest Android features for developing production-grade apps

Arrow left icon
Profile Icon Gema Socorro Rodríguez
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (6 Ratings)
Paperback Jul 2024 410 pages 1st Edition
eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Gema Socorro Rodríguez
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (6 Ratings)
Paperback Jul 2024 410 pages 1st Edition
eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Thriving in Android Development Using Kotlin

Building the UI for Your Messaging App

In this first chapter, we’re going to start building a messaging app called WhatsPackt (referring to a popular messaging app that you probably already know about). At this point in the project, we must make some important technical decisions and create the structure needed to build it. This is what we will be focusing on, as well as working on the app’s user interface.

By the end of this chapter, you will have hands-on experience creating a messaging app from scratch, organizing and defining the app modules, deciding which dependency injection framework you will use, using Jetpack Navigation to navigate between the app features, and using Jetpack Compose to build the main parts of the user interface.

This chapter is organized into the following topics:

  • Defining the app structure and navigation
  • Building the main screen
  • Building the chats list
  • Building the messages list

Technical requirements

Android Studio is the official standard integrated development environment (IDE) for developing Android apps. Although you can use other IDEs, editors, and Android tools if you prefer, all the examples in this book will be based on this IDE.

For that reason, we recommend that you set up your computer with the latest stable version of Android Studio installed. If you haven’t already, you can download it here: https://developer.android.com/studio. By following the installation steps, you will be able to install the IDE and set up at least one emulator with one Android SDK installed.

Once installed, we can start creating the project. Android Studio will offer us a set of templates to start with. We will choose the Empty Activity option, as shown in the following screenshot:

Figure 1.1: Android Studio new project template selection with the Empty Activity option selected

Figure 1.1: Android Studio new project template selection with the Empty Activity option selected

You will then be asked to select a project and package...

Defining the app structure and navigation

Before designing the app structure, we must have a basic idea of the features it should include. In our case, we want to have the following:

  • A main screen to create new or access already existing conversations
  • A list containing all the conversations
  • A screen for a single conversation

As this is going to be a production-ready app, we must design its code base while considering that it should be easy to scale and maintain. In that regard, we should use modularization.

Modularization

Modularization is the practice of dividing the code of an application into loosely coupled and self-contained parts, each of which can be compiled and tested in isolation. This technique allows developers to break down large and complex applications into more manageable parts that are easier to maintain.

By modularizing Android applications, modules can be built in parallel, which can significantly improve build time. Additionally,...

Building the main screen

Now that we have the main structure of our app ready, it is time to start building the main screen.

Let’s analyze what components our main screen will have:

Figure 1.9: The ConversationsList screen

Figure 1.9: The ConversationsList screen

As you can see, we are going to include the following:

  • A top bar
  • A tab bar to navigate to the main sections (note that this book will only cover the development of the chat section; we will not cover the status and calls sections)
  • A list containing the current conversations (which we will complete later in this chapter)
  • A floating button to create a new chat

Let’s start with the main screen.

Adding a scaffold to the main screen

Previously, we created an empty version of the first screen (ConversationsListScreen), as follows:

package com.packt.feature.conversations.ui
import androidx.compose.runtime.Composable
@Composable
fun ConversationsListScreen(
    onNewConversationClick...

Creating the conversations list

In this section, we are going to create all the pieces we need to show the conversations list. We will start with the UI data model, which will represent the information that the app is going to show in the list, the Conversation composable, which will draw every item of the list, and finally the list composable itself.

Modeling the conversation

First, we are going to model what is going to be the entity we will be using through our conversations list components: the Conversation model.

As part of the conversation model, we want to show the avatar of the other participant (we are just doing one-to-one conversations), their name, the first line of the last message, the time the message was received, and a number indicating how many unread messages there are.

Taking that information into account, we will start creating a data class to hold the data we’ll need:

data class Conversation(
    val id: String,
 ...

Building the messages list

In this section, we are going to create the UI models that are needed to create the chat screen and the messages two users could have exchanged. Then, we will create the Message composable, and finally, the rest of the screen, including the list of messages.

Modeling the Chat and Message models

Taking into account the information we have to show on the chat screen, we are going to need two data models: one for the static data related to the conversation (for example, the name of the user we are talking to, their avatar, and so on) and one data model per message. This will be the model for the Chat model:

data class Chat(
    val id: String,
    val name: String,
    val avatar: String
)

In this case, we will need the ID of the chat, the name of the person we are talking to, and their avatar address.

Regarding the Message model, we will create the following classes:

data class Message...

Summary

In this first chapter, we started our first project, WhatsPackt, a messaging app.

We accomplished several initial tasks to build this app, such as organizing modules, preparing dependency injection and navigation, constructing the main screen, creating the conversations list, and building the messages list.

Throughout this process, we’ve learned about modularization and the various approaches to organizing it. We’ve also learned about popular libraries for managing dependency injection, how to initialize them, and how to set up Compose navigation. Additionally, we became familiar with using Jetpack Compose to create our user interface.

As we move forward, it’s time to give some love and life to our chats. In the next chapter, we will explore how to retrieve and send messages and integrate them into our recently created user interfaces.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Understand complex concepts in a coherent way by solving challenging real-world problems and developing three practical projects
  • Use the latest features of libraries in Jetpack Compose, Room, CameraX, ExoPlayer, and more
  • Leverage best practices for UI creation, app structure, data handling, and lifecycle management
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

With resources on Android and Kotlin abound, it’s difficult to find content that focuses on resolving common challenges faced by app developers. This book by Gema Socorro Rodríguez – a Google Developer Expert for Android with over 15 years of experience and a proven track record as an effective instructor – is designed to bridge the gap between theory and real-world application. It equips you with the skills to tackle everyday problems in Android development through hands-on projects. Under Gema's expert guidance, you’ll build three sophisticated Android projects. You'll start your development journey by building a WhatsApp-like application, learning how to process asynchronous messages reactively, render them using Jetpack Compose, and advance to creating and uploading a backup of these messages. Next, you’ll channel your creativity into Packtagram, an Instagram-inspired app that offers advanced photo-editing capabilities using the latest CameraX libraries. Your final project will be a Netflix-style app, integrating video playback functionality with ExoPlayer for both foreground and background operations, and implementing device casting features. By the end of this book, you'll have crafted three fully functional, multi-platform projects and gained the confidence to solve the most common challenges in Android development.

Who is this book for?

If you're a mid-level Android engineer, this book is for you as it will not only teach you how to solve issues that occur in real-world apps but also benefit you in your day-to-day work. This book will also help junior engineers who want to get exposed to complex problems and explore best practices to solve them. A basic understanding of Android and Kotlin concepts such as views, activities, lifecycle, and Kotlin coroutines will be useful to get the most out of this book.

What you will learn

  • Create complex UIs with Jetpack Compose
  • Structure and modularize apps with a focus on further scaling
  • Connect your app to synchronous and asynchronous remote sources
  • Store and cache information and manage the lifecycle of this data
  • Execute periodic tasks using WorkManager
  • Capture and edit photos and videos using CameraX
  • Authenticate your users securely
  • Play videos in the foreground and background and cast them to other devices

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 19, 2024
Length: 410 pages
Edition : 1st
Language : English
ISBN-13 : 9781837631292
Vendor :
JetBrains
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jul 19, 2024
Length: 410 pages
Edition : 1st
Language : English
ISBN-13 : 9781837631292
Vendor :
JetBrains
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 107.97
Thriving in Android Development Using Kotlin
€41.99
Kickstart Modern Android Development with Jetpack and Kotlin
€35.99
Mastering Kotlin for Android 14
€29.99
Total 107.97 Stars icon

Table of Contents

14 Chapters
Part 1:Creating WhatsPackt, a Messaging App Chevron down icon Chevron up icon
Chapter 1: Building the UI for Your Messaging App Chevron down icon Chevron up icon
Chapter 2: Setting Up WhatsPackt’s Messaging Abilities Chevron down icon Chevron up icon
Chapter 3: Backing Up Your WhatsPackt Messages Chevron down icon Chevron up icon
Part 2:Creating Packtagram, a Photo Media App Chevron down icon Chevron up icon
Chapter 4: Building the Packtagram UI Chevron down icon Chevron up icon
Chapter 5: Creating a Photo Editor Using CameraX Chevron down icon Chevron up icon
Chapter 6: Adding Video and Editing Functionality to Packtagram Chevron down icon Chevron up icon
Part 3:Creating Packtflix, a Video Media App Chevron down icon Chevron up icon
Chapter 7: Starting a Video Streaming App and Adding Authentication Chevron down icon Chevron up icon
Chapter 8: Adding Media Playback to Packtflix with ExoPlayer Chevron down icon Chevron up icon
Chapter 9: Extending Video Playback in Your Packtflix App Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(6 Ratings)
5 star 83.3%
4 star 0%
3 star 0%
2 star 16.7%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Leke Aug 22, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is beginner-friendly, easy to read, and understand. It introduces modern concepts, architecture, tools, and services to build great Android apps. With the use of Jetpack Compose, Hilt for dependency injection, Flows, multiple architectures, etc., you will get up to speed with building Android apps like a professional. I recommend this book to anyone and this is coming from a Senior Android Engineer.
Amazon Verified review Amazon
Paula Paris Jul 27, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is ideal for advanced software developers with a background in clean architecture. Gema's work will help you conquer the native Android domain by leveraging your past clean architecture experiences on iOS, Flutter, or similar platforms.These chapters cover aspects from disciplines, such as modularization by feature or dependency injection, to platform-specific technologies like Jetpack Compose or ExoPlayer. There's also great coverage of companion components beyond the client environment, such as Firebase, Amazon S3, and other cloud-based technologies.I'm extremely happy with this book. I learned topics like WebSockets, that I had been wondering about for a long time. And I also got a deeper understanding on subjects that I knew, although to a lesser extent.I can't give less than 5 stars. Excellence!
Amazon Verified review Amazon
Amazon Customer Jul 27, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I found this book really helpful! I struggled to find information online on how to use Websockets, ExoPlayer or CamareX filtres. This book covers these areas and many more. I can't wait to put everything I've learned here into practice and I can definitely see myself keeping this manual close as a reference in my day to day. I really hope there is a follow up to go deep into other aspects of these apps!
Amazon Verified review Amazon
Steven Aug 28, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
"Thriving in Android Development Using Kotlin" is a practical and hands-on guide that elevates your Android development skills by addressing real-world challenges using the latest Android framework and Kotlin features. The book is structured around three well-thought-out projects inspired by popular apps like WhatsApp, Instagram, and Netflix, which progressively advance your skills from messaging apps to more complex applications involving photo editing with CameraX and video streaming using ExoPlayer. Each project focuses on solving specific challenges, such as handling asynchronous messages, building complex UIs with Jetpack Compose, and managing multimedia operations, providing an immersive learning experience.
Amazon Verified review Amazon
Pavan Vulisetti Aug 31, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
"Thriving in Android Development Using Kotlin" is an excellent guide for beginner and mid-level Android engineers looking to enhance their skills. The book adeptly navigates through foundational concepts of Kotlin and Android development, making it accessible for newcomers while offering valuable insights and techniques that resonate with more experienced developers.It provides clear explanations and practical examples for beginners that demystify core principles. Intermediate developers will appreciate its deeper dives into advanced topics, which are crucial for scaling up applications effectively.The book's strength lies in its structured approach, combining theoretical knowledge with hands-on exercises and real-world scenarios. This blend accelerates learning and cultivates a deeper understanding of best practices and industry standards in Android development. Overall, "Thriving in Android Development Using Kotlin" is a recommended read for anyone serious about mastering Kotlin for Android, offering a comprehensive pathway to proficiency in the field.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.