Skip to main content

Posts

Showing posts from February, 2017

Android Activity Lifecycle Callbacks

Android provides us with a pretty decent number of callbacks to handle the UI changes in our app, be it activities or fragments. In fact in case of fragments, they are so much such that making a flowchart out of them can actually scare any developer (See this ). Activities on the other hand provide a very reasonable no of callbacks and each one of them seems to have a separate use case. Most people already know about the callbacks that the activities provide at their individual level, but what they don't know about is this : Application.ActivityLifecycleCallbacks . Neither the android developer docs say anything about this interface nor they are referenced from somewhere else in the docs. Use case of this interface is pretty simple : If you want to do something after a particular callback (a UI state change) for each activity, you shouldn't be going to every activity that you have and override that method. A very basic example of this which comes to my mind when talk