Using Intents to Launch Activities

The most common use of Intents is to bind your application components. Intents are used to start, and transition between, Activities.

The instructions given in this section refer to starting neiv Activities, but the same details also apply to Services. Details on starting (and creating) Services are available in Chapter 9.

To open an Activity, call startActivity, passing in an Intent as shown in the following snippet:


The Intent can either explicitly specify the Activity class to open, or include an action that an Activity must perform. In the latter case the run time will choose an Activity dynamically using a process known as Intent resolution.

The startActivity method finds and starts the single Activity that best matches your Intent.

When you use startActivity your application won't receive any notification when the newly launched Activity finishes. To track feedback from the opened screen use the startActivityForResult method described in more detail in the next section.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment