As we all know, the most important thing in Android's four components is activity. And as a developer, the most we should focus on, of course, is the life cycle of activity.
When it comes to the activity life cycle, the best way is, of course, to explain it through flowcharts, here's the Official chart:
This is a bunch of e-Text flow chart, how to understand it? Can be understood as a dog blood of the palace fight drama.
Activity is like a show girl, full of battles and ups and downs throughout the life cycle.
"Little Show Girl" activity in the life of four states:
1. "Harem 3,000 people, 3,000 pampered in one" (Active State): Live in the Yuk Xiu Palace (front desk), have Heaven Yan (user), at any time may be pro lucky (get focus);
2. " Smell the beauty of the new entry, six palaces have not seen a moment of sorrow "(suspended state): Come out to mix, sooner or later to change, the newcomer came, the old man can only make room, let out the Yuk Xiu Palace (front desk), but by virtue of the past friendship, temporarily still can see the emperor (still visible), just every night vacant, not to get the rain (not the focus);
3. "This year, laughter, twists easy" (stop State): Autumnal matron, was driven into the limbo, difficult to see Emperor (not visible), more than the possibility of being lucky (lose focus);
4. "Xuan Zong returned to Ma Yangfei dead, the Rain unforgettable Sun and Moon new" (Destruction State): Perish, ended a miserable life.
Of course, these four states do not follow the linear step-by step, how can this show the story of Dog blood? Google's "screenwriter" to "Little Show girl" left some life-changing plot, when these episodes, the writers can take the opportunity to add their own plot:
OnCreate (Bundle Savedstatus) (draft, activity creation Si cho is used): Just like the TV show, our "little girl" want to enter the palace (into the stack, the activity of Android is stored in the stack, So follow the first-out rules) must pass the draft, dress up to let the emperor look, put on new clothes, make-up (generally in this callback function loading UI initialization and data initialization), show talent (data initialization), of course, the draft can only participate in a lifetime (this method will only be called once), Unless the reincarnation is reincarnation (after the application terminates, the user restarts the activity);
OnStart () (Enter the palace, the activity is invoked at the start of the event): The palace is usually only once, but some special circumstances may have the opportunity to returned, followed by the face Saint (Get Onresume ());
Onrestart () (legendary returned, called when the activity is restarted): Dramatic returned, possibly the change of the Emperor's mind (the activity is returned before the activity is destroyed, just as it would go back to the previous page when clicked back);
Onresume () (Into the palace face, get the focus of the call): to face the holy, Advanced Palace, must appear in the OnStart (), because the makeup is better, the face of the holy after the natural is favor, is the former said the activity State;
OnPause () (out of favor, suspended when the activity is called): The newcomer came, after the honeymoon period naturally prone to fall out of favor, into a miserable suspended state, there may be directly to give white damask three feet (users directly end the current application process), there may be hit to limbo (become translucent, the user can see, but can not operate, For example, when the user pulls down the status bar, the translucent status bar or vaguely see the activity of the interface, more OnCreate (), often rewritten, such as the user is watching the video, the girlfriend to the phone, we have to help him save his play progress in advance, Waiting for a child after the user back to continue to see), waiting for the old death or the opportunity to look for a comeback (user return to the original interface, Onresume () method is callback);
OnStop () (autumnal matron, called when the activity is stopped): The old Emperor did not want to agree, enter the nasty stop state, the only hope is the emperor's Change of heart (the user restarts the activity, let it re-enter the foreground of the user visual State, At the same time the Onrestart () method is called);
OnDestroy () (called when the activity is destroyed): The protagonist is going to hang up, and all departments are starting to pack things up (when the user clicks Exit or return, the method is called, the activity is recycled and destroyed), and the state of destruction is entered.
Well, after my some nonsense, presumably everyone more confused, haha.
Android's activity life cycle