Android life cycle turn off device11/25/2023 Hence, all in all there are four states of an Activity(App) in Android namely, Active, Paused, Stopped and Destroyed.įrom the user's perspective, The activity is either visible, partially visible or invisible at a given point of time. When we finally destroy the App i.e when we completely close it, then it is said to be in DESTROYED state.This state of the App is said to be STOPPED state. When we press the Home button while using the app, our app doesn't closes.In such a situation, the Activity is said to be in PAUSED state. At that point of time, we are not able to interact with the App's UI until we deal with that dialog box/popup. When any dialog box appears on the screen, like when you press exit on some apps, it shows a box confirming whether you want to exit or not.And the App or Activity starts running and it is said to be in ACTIVE state. When a user clicks on the App icon, the Main Activity gets started and it creates the App's User Interface using the layout XMLs.Starting from a user clicking on the App icon to launch the app, to the user exiting from the App, there are certain defined states that the App is in, let's see what they are. Similarly, when the user presses the App icon, the Main Activity is called and the execution starts from the onCreate() method of the Activity class.ĭifferent States of App (or, the main App Activity) For example, In Java programming (or programming languages like C or C++), the execution of the program always begin with main() method. There can be multiple Activities in Android, but there can be only one Main Activity. So apart from controlling the app, Activity also controls creation, destruction and other states of the App's lifecycle. But an Activity is responsible to create and destroy an App infinite number of times. One thing that is different here in context to our example is, that a human is created once at birth, and is destroyed once at death, and for the time in between is controlled by the mind/soul/concious. But what is the mind or soul or concious of our App? Yes, it is the Activity.Īctivity is nothing but a java class in Android which has some pre-defined functions which are triggered at different App states, which we can override to perform anything we want.Īctivity class provides us with empty functions allowing us to be the controller of everything.įor example, if we have a function specified by our mind → onSeeingSomethingFunny(), although we know what happens inside this, but what if we can override and provide our own definition to this function. ![]() In case of Android → Views, Layouts and ViewGroups are used to design the user interface, which is the physical appearence of our App. ![]() So in a way, we can say that our body is just a physical object while what controls us through every situation is our mind(soul or concious). What happens to us in the real world physically(getting hurt, seeing, hearing etc) are intrepeted by our mind(concious or soul) and we think or operate as per. Human mind or concious is responsible for what we feel, what we think, makes us feel pain when we are hurt(physically or emotionally), which often leads to a few tears, laughing on seeing or hearing something funny and a lot more. In this tutorial we will leanr about one of the most important concept related to Android development, which is Activity.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |