O'Reilly logo
live online training icon Live Online training

Kotlin for Android

Building modern Android applications using the Kotlin programming language

Ken Kousen

If the overwhelming use of Kotlin at the recent Google I/O conference is any indication, Kotlin is not just a supported language for Android; it's the de facto standard. Its combination of object orientation and powerful functional features leads to smaller, more optimized applications. Kotlin also provides a variety of extension libraries specifically designed to simplify Android development, and the official Android IDE, Android Studio, is produced by the same company that controls the language, so IDE support is also excellent.

The growth of Kotlin as an Android development language has been explosive. If you are developing for Android devices, you need to become comfortable with the language, both for native development and because more and more tutorials and support libraries are adopting it. Join Ken Kousen to gain an understanding of Kotlin fundamentals and learn how it streamlines Android development—making your job as a developer much easier.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • The fundamentals of the Kotlin programming language
  • How Kotlin simplifies Android code when compared to Java
  • Kotlin extension libraries and how to use them

And you’ll be able to:

  • Write Android applications in Kotlin
  • Use Kotlin features like lambdas, operator overloading, and delegation
  • Add extension functions to an application and use them to streamline development of layouts, SQL code, and more

This training course is for you because...

  • You're an Android developer who wants to use Kotlin for your next project.
  • You maintain Android applications and need to understand how Kotlin implementations differ from regular Java.
  • You're a developer who wants to use state-of-the-art concepts like lambdas, delegation, sealed classes, and more.
  • You'd like to use the new Kotlin extension libraries that further simplify Android development.

Prerequisites

  • A working knowledge of Java or another object-oriented language
  • Basic knowledge of Android development (equivalent to that covered in the live online training course Basic Android development
  • Familiarity with Kotlin (useful but not required)

Recommended preparation:

Take Basic Android development (live online training with Ken Kousen)

Recommended follow-up:

About your instructor

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Day 1

Introduction to Kotlin and Android Studio (30 minutes)

  • Lecture: What is Kotlin?; the Android Studio IDE; getting help
  • Hands-on exercise: Start a basic app in Android Studio with Kotlin

Android activities (45 minutes)

  • Lecture: Adding Kotlin support to your app; working with activities; classes and functions in Kotlin; constructors and function parameters
  • Hands-on exercise: Add an activity to your app

Break (10 minutes)

Variables and properties (15 minutes)

  • Lecture: Immutability in Kotlin; var and val declarations; type inference

Flow control (15 minutes)

  • Lecture: Using if expressions; the when keyword; loops and ranges

Lambda expressions and method references (45 minutes)

  • Lecture: Functional programming concepts; syntax for lambdas; replacing anonymous inner classes; method reference syntax
  • Exercise: Use lambdas for widget listeners

Break (10 minutes)

Data classes (30 minutes)

  • Lecture: Defining data classes; generated methods; using the copy() function

Break (10 minutes)

Database access (60 minutes)

  • Lecture: Using the SQLite database; performing a request in a background thread; mapping data classes to tables
  • Hands-on exercise: Convert table data to objects

Day 2

Interfaces and top-level functions (30 minutes)

  • Lecture: Code in interfaces; alternatives to "static" from Java; companion objects

Application singletons and delegated properties (60 minutes)

  • Lecture: Creating a singleton; using delegation; standard delegates
  • Hands-on exercise: Use singletons and companion objects

Break (10 minutes)

Property delegations and operator overloading (30 minutes)

  • Lecture: Overloading operators; late and lazy initialization; delegating to other classes and interfaces

Break (10 minutes)

Testing (60 minutes)

  • Lecture: Kotlin facilities for testing; implementing tests in Kotlin; Kotlin libraries for testing
  • Hands-on exercise: Perform unit and integration testing

Break (10 minutes)

Sealed classes (30 minutes)

  • Lecture: Defining a sealed class; using instances

Extension libraries (30 minutes)

  • Lecture: Anko; Android Kotlin Extensions