Passing Data Between Activities
Now that you have a MainActivity and a CheatActivity, you can think about passing data between them. Figure 7.7 shows what data you will pass between the two activities.
Figure 7.7 The conversation between MainActivity
and CheatActivity
The MainActivity will inform the CheatActivity of the answer to the current question when the CheatActivity is started.
When the user presses the Back button to return to the MainActivity, the CheatActivity will be destroyed. In its last gasp, it will send data to the MainActivity about whether the user cheated.
You will start with passing data from MainActivity ...
Get Android Programming: The Big Nerd Ranch Guide, 5th Edition 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.