Book Image

Learning Kotlin by building Android Applications

By : Eunice Adutwumwaa Obugyei, Natarajan Raman
Book Image

Learning Kotlin by building Android Applications

By: Eunice Adutwumwaa Obugyei, Natarajan Raman

Overview of this book

<p>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 means that it's even easier for developers to use.</p> <p>This book adopts a project-style approach, where we focus on teaching Android development by building three different Android Application: a Tic-Tac-Toe application, a location- based alarm and a To-Do list application.</p> <p>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 and as you progress through the chapters and the building of the different applications, the difficulty level will steadily grow.</p> <p>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.</p> <p>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.</p> <p>As a bonus chapter, you will also learn how to use the Google Faces API to detect faces and add fun functionalities.</p>
Table of Contents (21 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

AlarmManager


Reminders in android can best be implemented by using the AlarmManager. Why? See what the official documentation has to say about it:

These allow you to schedule your application to be run at some point in the future.

Additionally:

The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running. For normal timing operations (ticks, timeouts, and so on) it is easier and much more efficient to use Handler.

This means you have come to the right place if you want to implement such a feature as a reminder. The alternative class to handle such a task, Handler, is best suited for tasks that are expected to be completed while the app is still in use. Your app will definitely have reminders spanning days, and probably weeks or months, so it is best to use the AlarmManager class.

This is how it will work, your app will start a background service to kick off the timer for the reminder, then send a...