Android Core Specific Interview Questions: What to Expect and How to Prepare

Abi Farhan
1 min readMar 27, 2023

--

1. What happens when onDestroy() activity life callback method?

When onDestroy is called, the activity is on it is way out, meaning is about to be entirely removed from this stack in memory. When the activity is created to when there are for instance, interruptions such as that there is new activity becomes visible and the current activity goes into the background at some point in between the activity lifecycle onDestroy called by the time on the story is called, the activity is about to be killed by an Android system.

2. Why is said setContentView called in onCreate() method?

The setContentView is the method called to set up the user interface by pulling in the examiner layout resource served as the app screen. Then we know that the onCreate method is another lifecycle callback method. The setContentView method has responsible for pulling in the examiner layout resource file that serves as the app screen, what the user sees and interacts with now and when the activity goes through a lifecycle each lifecycle has a callback function attached to it and the onCreate is one of them and in this state the activity is about to be visible to the user. That is why this is the best place to bootstrap everything needed before the activity is actually in the foreground visible to the user. That is why setContentView is called inside the onCreate() method

--

--

Abi Farhan

Professional Android Developer, Software Developer. Photography Enthusiast