
Intents are categorized as either explicit or implicit.Īn explicit intent requests the launch of a specific activity by referencing the component name (which is actually the Java class name) of the target activity. Though not covered until later chapters, it is also worth highlighting the fact that, in addition to launching activities, intents are also used to launch and communicate with services and broadcast receivers. Similarly, the receiving activity may also be configured to return results data to the sending activity when the required tasks are completed.

In the previously outlined scenario, for example, the sending activity would need to send the URL of the web page to be displayed to the second activity. Intents also allow for the transfer of data from the sending activity to the receiving activity. The runtime system will match the request to available activities on the device and either launch the activity that matches or, in the event of multiple matches, allow the user to decide which activity to use. Rather than the application having to contain a second activity to perform this task, the code can simply send an intent to the Android runtime requesting the services of any activity that has registered the ability to display a web page. Consider, for example, an activity contained within an application that requires a web page to be loaded and displayed to the user. Intents also, however, go beyond this concept by allowing an activity to request the services of any other appropriately registered activity on the device for which permissions are configured.

An activity can, for example, issue an intent to request the launch of another activity contained within the same application.

Intents () are the messaging system by which one activity is able to launch another activity.

Prior to working through some Android Studio based example implementations of intents in the following chapters, the goal of this chapter is to provide an overview of intents in the form of explicit intents and implicit intents together with an introduction to intent filters. As outlined briefly in the chapter entitled The Anatomy of an Android Studio Android Application, this is achieved primarily using Intents. An area that has yet to be covered in extensive detail, however, is the mechanism by which one activity can trigger the launch of another activity. Purchase the fully updated Android Studio Dolphin Edition of this publication in eBook ($29.99) or Print ($49.99) formatĪndroid Studio Dolphin Essentials - Java Edition Print and eBook (PDF) editions contain 87 chapters and over 800 pagesīy this stage of the book, it should be clear that Android applications are comprised, among other things, of one or more activities. You are currently reading the Android Studio 1.x - Android 5 Edition of this book.
