Pick the fix
The app crashes when users switch away from a gallery screen that saves 500 thumbnails in onSaveInstanceState. Best fix?
Hint 1 of 1
What is the smallest data that can rebuild this screen?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Save only the IDs and scroll position, and reload thumbnails from the cache
Correct. The saved Bundle must be small; data belongs on disk.
Why not the others?
- B Compress the thumbnails before saving. Still large, and still shares the Binder buffer.
- C Catch TransactionTooLargeException. It's thrown by the system on the way out; you can't reliably catch it.
- D Save them in a static field. That won't survive process death, which is why state is saved in the first place.