Android from the foundation · check

Know The machinery already?

One question for each of the 4 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 13: Inside a Binder call

Your main thread calls a method on a proxy, and system_server takes 2 seconds to answer. What does the user see?

Not quite. The calling thread waits until the reply comes back. If it's the main thread, nothing else on screen runs. Learn it in puzzle 13 →

Right. A Binder call waits for its reply, so slow calls don't belong on the main thread.

Not quite. Binder doesn't give up: your thread waits for the reply. Learn it in puzzle 13 →

Puzzle 14: The main thread's queue

Two Binder threads receive a message for your screen at the same moment. Can your buttons and text be changed by both at once?

Not quite. Neither Binder thread touches the screen: they post to the queue, and only the main thread runs it. Learn it in puzzle 14 →

Right. The queue turns many senders into one worker, in order.

Puzzle 15: Frames, jank and ANRs

A button's click code calls Thread.sleep(6000), and the user taps the screen again right away. What happens?

Not quite. Touches are messages for the main thread too, so they wait behind the sleeping onCreate(). Learn it in puzzle 15 →

Right. One message at a time: the touch waits behind the sleep, and after 5 seconds comes the ANR.

Not quite. Nothing is stopped: system_server shows a dialog and the user decides. Learn it in puzzle 15 →

Puzzle 16: How big can a Binder call be?

You put a 3 MB photo into an Intent and start an Activity. What happens?

Not quite. The buffer has a fixed size of about 1 MB. A Parcel that doesn't fit fails; it doesn't wait. Learn it in puzzle 16 →

Not quite. Objects can't leave a process: the Intent is packed into a Parcel and must fit the receiver's Binder buffer. Learn it in puzzle 16 →

Right. Every Intent crosses Binder, through a buffer of about 1 MB.

Back to the overview →