Different states of Android Activity
An Android Activity has 4 States
Now there is a very unclear Demarcation among them if you just started learning Android application development. I will try to explain it in simple terms. So hang on!
When a user is actively interacting with an Activity then the activity is in Running State.
When a partial or a transparent Dialog/Activity gets focus on the top of the previous Activity then the Activity goes to the paused state.
You can see that the dialog partially hides the “Profile Activity”. The profile Activity is still visible but the user can not interact with it because the dialog has gained the focus. In this case, the Profile Activity goes to the paused state.
When an activity gets completely hidden by another Activity or dialog then the Activity goes to stop state.
You can see the profile Activity gets completely hidden by Another Activity.
There are two main reasons when an activity goes to the destroyed state.
- Android OS
Android OS: When an activity remains in background for way too long. Then there is a possibility that the Android OS may destroy your Activity to free up some space for more important tasks.
You: When you call finish() method in the Activity then the activity goes to the destroyed state.
I know I have not covered the lifecycle methods and Activity Backstack while explaining the states. But the idea was to keep this article as simple as possible. Hope you all liked it.
Putting up content takes a lot of time and effort 😓.
👏 clap 👏 If you think you learned something from this article.You can find me on Stackoverflow,Github,and,on Linkedin.
Give feedback and feel free to correct mistakes.