How would a robust app (like Pandora) lets say, retain state


In “For the more curious” it talks about the function onRetainNonConfigurationInstance() and how it was used to retain mediaPlayer objects upon rotation before fragments were a thing.

This made me wonder about apps like pandora that play music files, but if I pause and exit the app for a long amount of time, it knows exactly where it is when i start it back up. Obviously this isn’t an issue of retaining upon rotation, but retaining state of a mediaPlayer with something like onSavedInstanceState() but how can you save the state of a media player like that in the activity record?

Secondly, do all modern apps use fragments now-a-days to retain objects across rotation? How common is it? The book says that the developer pages doesn’t really encourage the use of setRetainInstance() so then what is the proper method?