Book Image

Android Programming with Kotlin for Beginners

By : John Horton
5 (1)
Book Image

Android Programming with Kotlin for Beginners

5 (1)
By: John Horton

Overview of this book

Android is the most popular mobile operating system in the world and Kotlin has been declared by Google as a first-class programming language to build Android apps. With the imminent arrival of the most anticipated Android update, Android 10 (Q), this book gets you started building apps compatible with the latest version of Android. It adopts a project-style approach, where we focus on teaching the fundamentals of Android app development and the essentials of Kotlin by building three real-world apps and more than a dozen mini-apps. The book begins by giving you a strong grasp of how Kotlin and Android work together before gradually moving onto exploring the various Android APIs for building stunning apps for Android with ease. You will learn to make your apps more presentable using different layouts. You will dive deep into Kotlin programming concepts such as variables, functions, data structures, Object-Oriented code, and how to connect your Kotlin code to the UI. You will learn to add multilingual text so that your app is accessible to millions of more potential users. You will learn how animation, graphics, and sound effects work and are implemented in your Android app. By the end of the book, you will have sound knowledge about significant Kotlin programming concepts and start building your own fully featured Android apps.
Table of Contents (33 chapters)
Android Programming with Kotlin for Beginners
Contributors
Preface
Index

Basic classes app and using the init block


You can get the completed code for this app in the code download. It is in the Chapter10/Basic Classes folder. But it is most useful to read on to create your own working example.

We will create a few different classes using what we have learned throughout this chapter to put the theory in to practice. We will also see our first example of how classes can interact with each other by passing a class as a parameter into the function of another class. We know how to do this in theory already, we just haven't seen it in practice yet.

We will also see another way to initialize our data when the class is first instantiated by using an init block.

We will create a small app that plays with the idea of simulating ships, docks, and sea battles.

Note

The output for the apps in this chapter and the next will be just text to the logcat window. In Chapter 12, Connecting our Kotlin to the UI and Nullability, we will bring together everything we learned in the first...