How Many States Does an Activity Have?

The Activity lifecycle section in the Application Fundamentals tutorial states that there are 3 states:

An activity has essentially three states:

(1. active/running 2. paused 3. stopped)

But then as I continued reading the actual Activity class documentation, the Activity Lifecycle section states that there are 4 state:

An activity has essentially four states:

(1. active/running 2. paused 3. stopped 4. "dropped"?)

Both sources (on the same website) agree about the first 3, but the 4th one is only mentioned in the class documentation and is unnamed.

So, are there really 4 states or only 3?

If there are 4, what is the name of the 4th one?

Please help me understand this discrepancy.

Also, highlighted colored blocks in this beautiful and very informative flowchart don't seem to correspond to the states. Where, in the flowchart, would you mark the 3 or 4 states?

Answers


I would describe it as three states. The fourth "state" is non-existence, in that Android may destroy the activity to free up RAM. However, if that activity is still reachable via the BACK button, Android will hang onto the Bundle from onSaveInstanceState() and use that when it recreates the activity. If you wish to consider this cached Bundle a "state", I wouldn't quibble, but it's not the way I usually describe it.

Also, highlighted colored blocks in this beautiful and very informative flowchart don't seem to correspond to the states.

Mostly, that diagram is showing the sequence of the lifecycle methods. As you say, it is a flowchart, more so than a state diagram.

Where, in the flowchart, would you mark the 3 or 4 states?

I wouldn't. However, the active/running state is the green "activity is running" bubble, the paused state is the white "The activity is no longer visible" bubble, and the stopped state would be in between onStop() and onDestroy(). The non-existence "state" would be the red "Process is killed" bubble.


This diagram depicts 4 states, the 4th being labeled Destroyed.

However, as you can see, this 4th "state" leads nowhere. That is, unlike the 3 other states which are "leave-able" to another state, this "Destroyed" state is a dead end.


Need Your Help

Looping if statement trouble

java loops if-statement

I've just started beginning program and my professor is having us write a program that counts votes. The concept is looping but I'm having trouble with it. The program is supposed to get an input of

Why is is_lock_free a member function?

c++ c++11 std atomic

What is the reason for why is_lock_free requires an instance (it's a member function)? Why not a metafunction of the type, or a static constexpr member function?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.