Activity life cycle

Activity's life cycle is very clear at the android developer website. When try to start an activity, the main function in ActivityThread.java will run first, it will then enter the loop function in Looper.java. Loop function is responsible for the get the message from a message queue and dispatch the message out. Looks like all the message about life cycle will enter to this message queue. The message dispatched from looper will be handled by handleMessage function in ActivityThread.java. All the message about life cycle will be handled here, the message includes activity launch, pause, resume, start, stop, destroy, service bind and others. The below flow chart shows how the message to handle.



How about the life cycle when launch an son activity from a main activity? Below flow chart shows the states of the two activity.



猜你喜欢

转载自blog.csdn.net/wowo1109/article/details/7012799