When activity A starts activity B in a different application, activity B is said to be re-used. This use case normally takes place because activity A is lacking a capability and can find it in activity B.
Contacts Re-Uses Gallery to Get a Picture - The Contacts activity has a field for a picture of a contact, but the Gallery is normally where pictures are kept. So Contacts can re-use the Gallery activity to get a picture. This is a good example of re-use of the Gallery activity. The following figure illustrates the sequence of activities to do this (up to crop). This is how it's done: The user chooses Contacts, selects the contact for viewing, chooses MENU > Edit contact and touches the picture field, which launches the Gallery activity. The user then chooses the picture they want, crops and saves it. Saving it causes the picture to be inserted into the picture field in the contact.
Notice the Gallery returns a picture to the Contacts application that started it. The next example illustrates re-use of an activity that does not return a result. Also notice that the following figure is illustrates the navigation history through the activities, or the activity stack — the user can back up through each activity all the way to Home. When designing an application, it's good to think about how it can re-use activities in other applications, and how your activities might be re-used by other applications. If you add an activity with the same intent filter as an exisiting activity, then the system presents the user with a choice between the activities.
Gallery Re-Uses Messaging for Sharing a Picture - Sharing is another good example of one application re-using an activity from a different application. As shown in the following figure, the user starts Gallery, picks a picture to view, chooses MENU > Share, and picks "Messaging". This starts the Messaging activity, creates a new message and attaches the original picture to it. The user then fills in the "To" field, writes a short message and sends it. User focus remains in the Messaging program. If the user wants to go back to the Gallery, they must press the BACK key. (The user can back up through each activity all the way to Home.)
User chooses Share -Messaging
Messaging | New Message ]
In contrast to the previous example, this re-use of the Messaging activity does not return anything to the Gallery activity that started it. Both of these examples illustrate tasks — a sequence of activities that accomplish an objective. Each case uses activities from two different applications to get the job done.
Was this article helpful?