Book Image

Mastering Android Development with Kotlin

By : Miloš Vasić
Book Image

Mastering Android Development with Kotlin

By: Miloš Vasić

Overview of this book

Kotlin is a programming language intended to be a better Java, and it's designed to be usable and readable across large teams with different levels of knowledge. As a language, it helps developers build amazing Android applications in an easy and effective way. This book begins by giving you a strong grasp of Kotlin's features in the context of Android development and its APIs. Moving on, you'll take steps towards building stunning applications for Android. The book will show you how to set up the environment, and the difficulty level will grow steadily with the applications covered in the upcoming chapters. Later on, the book will introduce you to the Android Studio IDE, which plays an integral role in Android development. We'll use Kotlin's basic programming concepts such as functions, lambdas, properties, object-oriented code, safety aspects, type parameterization, testing, and concurrency, which will guide you through writing Kotlin code in production. We'll also show you how to integrate Kotlin into any existing Android project.
Table of Contents (24 chapters)
Title Page
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Executing our first API call


We defined a Retrofit service with all API calls, but we haven't connected anything to it yet. It is time to use it. We will extend our code to use Retrofit. Each API call can be executed synchronously or asynchronously. We will show you both ways. Do you remember that we set our Retrofit service base URL to the localhost? This means that we will need a local backend instance that will respond to our HTTP requests. Since backend implementation is not the subject of this book, we will leave it up to you to create a simple service responding to this request. You can implement it from any programming language you like, such as Kotlin, Java, Python, and PHP.

If you are impatient and don't want to implement your own application for dealing with HTTP requests, you can override the base URL, Notes, and TODOs paths as shown in the following example and use the backend instance ready for tryout:

...