Android from the foundation · check

Know Screens and their lives already?

One question for each of the 3 puzzles in this module. A right answer marks that puzzle as passed, so you can jump ahead. A wrong one tells you which puzzle to start with. Nothing is sent anywhere: it's saved in this browser.

Puzzle 17: Turn the phone, lose your screen

Your Activity keeps the list the user scrolled in a field. The user switches the phone to dark mode. What happens to the field?

Right. Any configuration change recreates the Activity.

Not quite. The process lives on, but the Activity object is a new one, and the old fields went with the old object. Learn it in puzzle 17 →

Not quite. Turning the phone is one configuration change of many; dark mode and language are too. Learn it in puzzle 17 →

Puzzle 18: The ViewModel outlives the screen

A ViewModel downloads a list when it's created, like the one above. The user turns the phone twice. How many times is the list downloaded?

Not quite. The Activities are new, but the ViewModel waits in the store and is handed over. Learn it in puzzle 18 →

Right. The store survives configuration changes, so the ViewModel and its list do too.

Not quite. The store is cleared only when the screen closes for good, not on a configuration change. Learn it in puzzle 18 →

Puzzle 19: When the process is gone

The user typed a long message, kept only in a ViewModel. They switch apps, and Android ends your process to free memory. They come back. What do they see?

Right. Only what was in the saved state (or in a file) comes back.

Not quite. system_server keeps only the small Bundle your app sent, never your objects. Learn it in puzzle 19 →

Not quite. A ViewModel lives in your process; when the process is gone, so is it. Learn it in puzzle 19 →

Back to the overview →