Learning Kotlin by building Android Applications

Book description

Learn programming in Kotlin including data types, flow control, lambdas, object-oriented, and functional programming while building 3 Android Apps

About This Book
  • Experience the gentle learning curve of Kotlin as you develop your own applications
  • Learn how to integrate Kotlin into Android Studio and use it in your projects
  • Build real-world applications such as Googly Eyes and games using Kotlin
Who This Book Is For

If you are completely new to Kotlin or the Android platform and need to publish Android applications for fun or for business purposes, but you have no clue where to start, then this book is for you. This book is also for advanced Android developers who want to learn to use Kotlin instead of/alongside Java for Android development, although having some programming experience would be advantageous.

What You Will Learn
  • Learn the basics of using the Android Studio IDE and a number of basic programming concepts in Kotlin
  • Discover Android development by building Android apps with Kotlin
  • Uncover some amazing features of Kotlin that give it the upper hand over Java
  • Kotlin Interoperability with Java
  • Integrate Crashlytics for crash reporting and beta testing.
  • Use Google Location services and understand various APIs available for getting user location updates
  • Understand the principles of networking and communication.
  • Learn about the usage of third-party libraries for loading of data
  • Automate your build process with continuous integration tools
In Detail

Today Kotlin is an official programming language for Android development and is widely adopted. Kotlin is expressive, concise, and powerful. It also ensures seamless interoperability with existing Android languages like JAVA and C++, which makes it easier to learn a new language for their most favored platform.

This book adopts a project-style approach, where we focus on teaching Android development by building three different Android Application, namely Building you Tic-Tac-Toe application, Developing your location based alarm and lastly a To-Do list application.

The book begins by giving you a strong grasp of the Kotlin language and its APIs as a preliminary to building stunning applications for Android. You'll learn to set up an environment as the difficulty level grows steadily, in line with applications covered in later chapters.

The book also introduces you to the Android Studio IDE, which plays an integral role in Android Development. It covers Kotlin's basic programming concepts such as functions, lambdas, properties, object-oriented code, safety aspects and type parameterization, testing, and concurrency, and helps you write Kotlin code to production.

Finally, you'll be taken through the process of releasing your app on the Google Play Store. You will also be introduced to other app distribution channels such as Amazon App Store.

As a bonus chapter, you will also learn how to use the Google Faces API to detect faces and add fun functionalities.

Style and approach

This book has a project-style approach where we focus on teaching Android development by building Android Apps with the Kotlin programming language. In the process you learn about Android development as well as Kotlin and its features. This book does not assume any prior knowledge of Android development.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Learning Kotlin by Building Android Applications
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  6. Setting Up for Android Development
    1. Why develop Android with Kotlin?
      1. Concise
      2. Say bye bye to the NullPointerException
      3. Java interoperability
    2. Setting up your environment
      1. Java
        1. Installing the JDK
      2. Android Studio
        1. Installing Android Studio
        2. Getting Android Studio ready
      3. Creating your first Android project
        1. Choosing an SDK
      4. Building your project
        1. Gradle
        2. Parts of an Android project
      5. Running your app
        1. The Android emulator
          1. Creating an Android emulator
          2. Running from an emulator
        2. Running on an actual device
    3. Summary
  7. Configuring Your Environment for Kotlin
    1. Installing the Kotlin plugin
    2. Making our project Kotlin-ready
      1. Kotlin alongside Java?
      2. Kotlin to Java?
    3. Summary
  8. Data Types, Variables, and Constants
    1. The user interface
      1. Building our game UI
    2. Basic types
      1. Variables and constants
      2. Properties
    3. Summary
  9. Classes and Objects
    1. Structure of a class
      1. Constructors
      2. Data classes
    2. Objects
    3. Summary
  10. Type Checks and Null Safety
    1. Null safety
      1. Nullable and non-nullable types
      2. Safe call operator
      3. The Elvis operator
      4. The !! operator
    2. Type checks
      1. Cast operator
    3. Summary
  11. Functions and Lambdas
    1. Functions
      1. Parameters
    2. Higher–order functions and lambdas
      1. Lambda expressions
    3. Implementing a game status check
    4. Summary
  12. Developing Your Location-Based Alarm
    1. Creating a project
    2. Generation of a Google Maps API key
      1. Running the app
    3. Understanding the code
    4. Customizing the code
      1. Finding the Lat and Lng of a place
      2. The XML layout
    5. Developing a screen for user input
    6. The AndroidManifest file
      1. Build.gradle
    7. Summary
  13. Working with Google's Location Services
    1. Integrating shared preferences
    2. Adding permissions
    3. Integration of the location API
      1. Classes and variables
    4. The Google API client
    5. Matching the location
    6. Summary
  14. Connecting the Outside World – Networking
    1. Network connectivity
      1. Manifest permissions
      2. Volley library
      3. Sync adapter
    2. Third-party libraries
      1. Picasso
        1. User interface – XML
        2. build.gradle
        3. Kotlin code
        4. Manifest permissions
      2. Glide
        1. build.gradle 
        2. Kotlin code
    3. Summary
  15. Developing a Simple To-Do List App
    1. Creating the project
    2. Building your UI
      1. Using the Android Studio layout editor
    3. Adding functionality to the user interface 
      1. Adding a new task
      2. Displaying data in the ListView
      3. Updating/deleting a Todo item
        1. Adding a menu
    4. Summary
  16. Persisting with Databases
    1. Introduction to databases
      1. Relational databases
        1. Using SQLite
          1. Inserting data into the database
          2. Retrieving data from the database
          3. Updating a task
          4. Deleting a task
        2. ORM libraries
          1. Retrieving data from the database
          2. Inserting data into the database
          3. Updating a task
          4. Deleting a task
      2. Non-relational databases
    2. Summary
  17. Setting Reminders for Tasks
    1. AlarmManager
      1. Creating the alarm
        1. Starting the reminder dialog
        2. BroadcastReceiver
          1. Sending broadcasts
          2. Creating a broadcast receiver
        3. Creating the AlarmService
          1. Creating an IntentService
    2. Firebase Cloud Messaging
      1. Integrating FCM
    3. Summary
  18. Testing and Continuous Integration
    1. Testing
      1. Importance of testing
      2. Android Testing Support Library
        1. Model-View-Presenter architecture
        2. Test-Driven Development
      3. Functional versus non-functional testing
        1. Notes app
        2. Test dependencies
          1. Your first test
      4. Crashlytics
        1. Connect
    2. Stages of testing
      1. Alpha testing
      2. Beta testing
        1. Setting up for beta testing
        2. Creating the beta test track
        3. The opt-in URL
      3. Continuous integration
        1. Definition
        2. Tools
        3. Installing fastlane
    3. Summary
  19. Making Your App Available to the World
    1. Key store generation
      1. Key store generation through Android Studio
        1. Auto signing the APK through Android Studio
          1. Build types and flavors
      2. Key store generation through the command line
    2. Publishing the app in Google Play Store
      1. App release section
      2. Store listing section
      3. Content rating section
      4. Pricing and distribution section
    3. Publishing the app in Amazon Appstore
      1. General information
      2. Availability & Pricing section
      3. Description section
      4. Images & Multimedia section
      5. Content Rating section
      6. Binary File(s) section
    4. Summary
  20. Building an App Using the Google Faces API
    1. Introduction to Mobile Vision
      1. Faces API concepts
      2. Getting started – detecting faces
        1. Creating the FunyFace project
        2. Loading the image
        3. Creating a Paint instance
        4. Creating a canvas
        5. Creating the face detector
      3. Detecting the faces
      4. Drawing rectangles on the faces
      5. Results
    2. Summary
  21. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Learning Kotlin by building Android Applications
  • Author(s): Eunice Obugyei, Natarajan Raman
  • Release date: June 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788474641