Starting an Activity

The simplest way one activity can start another is with the startActivity(Intent) function.

You might guess that startActivity(Intent) is a static function that you call on the Activity subclass that you want to start. But it is not. When an activity calls startActivity(Intent), this call is sent to the OS.

In particular, it is sent to a part of the OS called the ActivityManager. The ActivityManager then creates the Activity instance and calls its onCreate(Bundle?) function, as shown in Figure 6.7.

Figure 6.7  Starting an activity

Starting an activity

How does the ActivityManager know which Activity to start? That ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.