Android Certification Training Course
- 65k Enrolled Learners
- Weekend
- Self Paced
In our previous posts, we have explained how to create Android apps and games. However, those Android tutorials might appear advanced to a beginner with limited knowledge of the technology. Our series of Android Tutorials would help beginners get familiar with the basic concepts of Android. This Android tutorial discusses the activity component.
Let us take the example of your very own Facebook app. The log in screen is the first activity you see when you launch your Facebook app. After signing in, the next activity encountered is the news feeds screen.
To develop a successful application, it is important for the developer to map out the complete flow of activities based on the user’s action. This would ensure that the application behaves exactly as expected. Therefore, understanding the Activity Life-cycle is very important for developers.
Following are the different states in an Activity Life-cycle:
1) Starting State:
When an activity does not yet exist in memory, it is in the starting state.
2) Resumed/Running State:
An activity that is in the foreground is in the running state. Any activity that is currently on the screen and interacting with the user is the running activity at that particular point in time. It exists at the top of the activity stack.
3) Paused State:
When an activity is not in focus (i.e. not interacting with the user), but is still visible on the screen, it is in the paused state.
4) Stopped State:
An activity that is not visible on the screen, but exists in the memory is in the stopped state.
5) Destroyed State:
A destroyed activity results from the removal of an activity (that is no longer required) from the memory. Such removals generally occur, when the activity manager decides that there is no use for such activities anymore.
The activities go through their life-cycle using a stack mechanism. “Last in-first out” system operates in the Android Activity stack. Here’s a brief overview of how the Activity Back-stack works:
Whenever an activity goes through any change in its life cycle stages (for instance: When a running activity is paused), a callback method notifies it of this change. Whether the activity is being created, destroyed, or undergoing any other transition, there is a callback method to notify it. For each callback, there is a pre-defined behavior.
To ensure smooth transitions between different activities, the developer must implement callbacks beforehand. We shall discuss more on callbacks in subsequent Android tutorials. Stay put for that.
Happy Learning!
Got a question for us? Please mention it in the comments section and we will get back to you.
Related Posts:
Get started with Android Training
Top 5 Android Interview Questions for freshers
Android Tutorials for Beginners: Activity component
edureka.co
Quality articles is the crucial to attract the people to go to
see the website, that’s what this web site is providing.
Great explanation with all images but a video can also help to learn especially a nice video like this one
very helpful tutorials for beginners….
nice
nice..
I lik it..
very nice….helpful………..:)
Good One !!!
Can you please tell me how to know when activity is destroyed by user or it has been killed by process.
Activity 2 destroyed: As soon as the user’s work with the current activity (Activity 2) is over, and he presses the Back button, the original activity (Activity 2) comes to the foreground (after the system destroys the running activity). I think there is a small mistake here. after pressing the back button, the original activity (Activity 1) omes to the foreground, not Activity 2.
good one
http://www.vrukshtech.com