Chapter 3. Multiple Activities and Intents: State Your Intent
Most apps need more than one activity.
So far we’ve just looked at single-activity apps, which is fine for simple apps. But when things get more complicated, just having the one activity won’t cut it. We’re going to show you how to build apps with multiple activities, and how you can get your apps talking to each other using intents. We’ll also look at how you can use intents to go beyond the boundaries of your app and make activities in other apps on your device perform actions. Things just got a whole lot more powerful...
Apps can contain more than one activity
Earlier in the book, we said that an activity is a single, defined thing that your user can do, such as displaying a list of recipes. If your app is simple, this may be all that’s needed.
A lot of the time, you’ll want users to do more than just one thing—for example, adding recipes as well as displaying a list of them. If this is the case, you’ll need to use multiple activities: one for displaying the list of recipes and another for adding a single recipe.
An activity is a single focused thing your user can do. If you chain multiple activities together to do something more complex, it’s called a task.
The best way of seeing how this works is to see it in action. You’re going to build an app containing two activities. The first activity will allow you to type a message. ...
Get Head First Android Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.