[MUSIC] Welcome to the first part of the first lesson in our module on Android intents. This lesson provides an overview of Android intents. Which are a key part of the overall Android component framework. There's several learning objectives in this part of the lesson. By the time you complete this part of the lesson you'll know how intents allow the integration of apps that interact with or request functionality from other components. And you also recognize methods used to launch Android components via intents. This part of the lesson just focuses on concept's, rather than on code. We'll show plenty of code examples later in this module. Let's start by talking about how Android intents can be used to integrate components An intent is a message that one component uses to interact with or request functionality from other components. For example, this diagram illustrates three Apps: App1, App2, App3 and a number of components in those Apps. In app one, activity one request functionality from activity two using an intent. LIkewise, activity two and app one uses an intent to interact with a receiver component in app three. More over Activity1 and App1 uses and intent to start a service it interacts with in App2. Intents are essentially the glue that helps to integrate Android apps. App development is therefore simplified since existing components can e reused as black boxes. A black box is a component that only needs to be understood by its interface and not by its implementation. Let's take a look at a simple example. Consider an image download app that downloads an image from a remote web server and displays it to the user. We'll examine several variations of this app throughout the course. One way to build this app, of course, would be to write this whole thing from scratch. But that would become tedious and error prone very quickly. So instead what we're going to do is, we're going to write a main activity component that uses intents to obtain functionality from other components that already exist. For instance, we may already have written a DownloadService component that downloads an image from a remote website and stores it locally on the device and then returns a URI or path name to that image, back to the main activity. The main activity then takes that URI and passes it to the GalleryActivity component which is pre developed, it comes part of the Android release itself. And this GalleryActivity then goes around and displays the image via the Gallery app. The ImageDownloadApp is simplified since it integrates other existing components, such as DownloadService and the GalleryActivity, rather than having the application developer of the ImageDownloadApp write everything from scratch. Let's now talk a bit about the structure and functionality of intents. An intent is implemented as a so-called passive data structure. A passive data structure just consists of fields and field accessor and mutator methods. A passive data structure is sometimes referred to as a record or a pod, plain old data and it's not object oriented in the sense that it doesn't necessarily have virtual methods, dynamic binding, it may not use inheritance. It's really used to be passed around as a record or a set of fields. The next lesson will examine these fields and methods in greater detail. The data in the fields in an intent can be passed from one component to another. This approach is similar to communicating between objects by passing arguments to a method call. Android automatically handles the cases where components live in different processes. For example, here we see activity one in process1 passing an intent to service one in process2. Apps can use intents to describe two types of things. The first thing they can do is to find an operation to perform. For example, the ACTION_VIEW intent can be used to display data to the user. Likewise, the ACTION_CALL intent can be used to perform a call to someone specified by the data, such as a phone number. Android delivers the intent to the Activity or Service that can best handle it that's what we'll discuss later. And intent can also be used to describe an event that's already occurred. For example the action battery low intent indicates there's a low battery condition on an Android device. Likewise the ACTION_AIRPLANE_MODE_CHANGED intent Indicates the user has switched the phone into or out of airplane mode. Once again, Android delivers the intent to the broadcast receiver or receivers that can best handle it. Let's now discuss methods that are used to launch components via intents. A component invokes a method to send an intent to 0 or more components. And of course, these methods are provided by Android. The startActivity() and startActivityForResult () methods can be used to launch an activity With an action intent. There may be more than one activity that matches an intent so the Android underlying framework provides something called a chooser dialogue that allows the user to decide which activity they actually want to have to handle the event. Sendbroadcast() and various methods related to send broadcast are used to send event intents to a BroadcastReceiver. There can be 0 or more of these receivers depending on various conditions, which we'll discuss when we talk about intent filtering and intent resolution. And finally is a pair of methods, startService or bindService. It can be used to launch and communicate with a service via an intent. Unlike activities or receivers where there may be multiple potential recipients of the intent, an intent can only be sent to one service, which we'll discuss later as well. All the methods we discussed here pass the intents asynchronously. In other words, they don't block the caller while the various components carry out the operations in processing related to the intent. This is the End of the Overview of Android Intents Part 1. [MUSIC]