Networking Across Configuration Changes
Now that you have your app deserializing JSON into model objects, take a closer look at how your implementation behaves when a configuration change occurs. Run your app, make sure auto-rotate is turned on for your device or emulator, and then rotate the device quickly five or so times in a row. Inspect the Logcat output, filtering by PhotoGalleryFragment and turning soft wraps off (Figure 24.8).
Figure 24.8 Logcat output across multiple rotations
What is going on here? A new network request is made every time you rotate the device. This is because you kick off the request in onCreate(…) ...
Get Android Programming: The Big Nerd Ranch Guide, 4th 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.