Category: Kotlin
-
An Overview of Android Services
The Android Service class is designed to allow applications to initiate and perform background tasks. Unlike broadcast receivers, which are intended to perform a task quickly and then exit, services are designed to perform tasks that take a long time to complete (such as downloading a file over an internet connection or streaming music to…
-
A Kotlin Coroutines Tutorial
The previous chapter introduced the key concepts of performing asynchronous tasks within Android apps using Kotlin coroutines. This chapter will build on this knowledge to create an example app that launches thousands of coroutines at the touch of a button. Creating the Coroutine Example Application Select the New Project option from the welcome screen and,…
-
A Guide to Kotlin Coroutines
When an Android application is first started, the runtime system creates a single thread in which all components will run by default. This thread is generally referred to as the main thread. The primary role of the main thread is to handle the user interface in terms of event handling and interaction with views in…
-
Android Broadcast Intents and Broadcast Receivers
In addition to providing a mechanism for launching application activities, intents are also used to broadcast system-wide messages to other components on the system. This involves the implementation of Broadcast Intents and Broadcast Receivers, both of which are the topic of this chapter. An Overview of Broadcast Intents Broadcast intents are Intent objects that are…
-
An Android Implicit Intent Tutorial
This chapter will create an example application in Android Studio designed to demonstrate a practical implementation of implicit intents. The goal will be to create and send an intent requesting that the content of a particular web page be loaded and displayed to the user. Since the example application itself will not contain an activity…
-
An Android Explicit Intents Tutorial
The chapter entitled An Android Intents Overview covered the theory of using intents to launch activities. This chapter will put that theory into practice by creating an example application. The example Android Studio application project created in this chapter will demonstrate the use of an explicit intent to launch an activity, including the transfer of…
-
An Android Intents Overview
By this stage of the book, it should be clear that Android applications comprise one or more activities, among other things. However, an area that has yet to be covered in extensive detail is the mechanism by which one activity can trigger the launch of another activity. As outlined briefly in the chapter entitled Understanding…
-
The Android AppBar and CollapsingToolbar Layouts
In this chapter, we will explore how the app bar within an activity layout can be customized and made to react to the scrolling events occurring within other screen views. Using the CoordinatorLayout in conjunction with the AppBarLayout and CollapsingToolbarLayout containers, the app bar can be configured to display an image and to animate in…
-
An Android Studio RecyclerView Tutorial
This chapter will create an example project that uses both the CardView and RecyclerView components to create a scrollable list of cards. The completed app will display a list of cards containing images and text. In addition to displaying the list of cards, the project will be implemented such that selecting a card causes messages…
-
Android RecyclerView and CardView Overview
The RecyclerView and CardView widgets work together to provide scrollable lists of information to the user in which the information is presented as individual cards. Details of both classes will be covered in this chapter before working through the design and implementation of an example project. An Overview of the RecyclerView Much like the ListView…