Random Android Learnings
Follow my Medium page at https://medium.com/@ghbhatt Activity lifecycle on rotation We all learn that on rotation the Activity undergoes destruction and re-creation. To handle this, we often have listeners / weak references to the Activity that is detached and reattached in the onStop() and onStart() methods. These listeners are invoked when a long running task returns e.g your network call. In an interview, I was asked a question: what would happen if the call returned right at the time when the activity is destroyed but the new instance is not yet created? i.e what would happen when your long running task returned between the onStop() of the Activity being destroyed and onStart() of the Activity being recreated? At first, I was confused because it seemed like a really legit use case and I was wondering why I never thought about it. Needless to say, I didn't do well in that interview trying to give a really weird timing based solution but on the bright side, I learned a really va