2012年3月26日星期一

Dr Dre HeadphonesManagement of the Activitylife cycle through the realization of activity life cyc

Management of the Activitylife cycle through the realization of activity life cycle callback method to manage your activity ,is to create a stable and flexible activity key .Activity life cycle was directly related to other activity and its task and the stack effect .
A activity can exist three basic states :Resumed Activity is located on the top screen ,and having the user focus ,the user can manipulate it .( this condition is sometimes considered to be running ) .
Paused Activity B is located at the upper and the input focus ,acitvity A is located in the lower layer ,but activity A is still visible ,if activity A is in the Paused state .Activity A visible cause may be an activity B is translucent ,Five Fingers Shoes,or acitvity B does not cover the entire screen .
The state of the activity is still live ,because it is located in the memory, and it is the window manager manages .It provided access to the CPU time slice it can goes on the run ,of course system at this time is not to let it run ,so don give it CPU time slice .
The state of the activity in the RAM remaining few ,may be used by the system .Stoped if a Activity other activity completely covered ,so it is in the Stoped state .It is in the background .
The state of the activity is live ,it is still in memory ,but the window manager in it removed .However ,it is no longer seen by users and the system can be in other components require memory when killed it ,which means it is more likely to be killed paused state .
If an activtiy is paused or stoped status ,system can kill it .Kill it with the method has mild :request activity finish ( Dutch act ) ,or the direct use of violent methods :kill activity process .
However ,activity is removed from memory .When being killed or Dutch act activity restarts, it must be created from scratch .Implementation of public class ExampleActivity life cycle callback extends Activity {public voidonCreate ( Bundle savedInstanceState ) { / / Theactivity is being created.
@ Override super.onStart ( ) ;} protected voidonResume ( ) { / / Theactivity has become visible ( it is now " ;resumed" ;@ Override ( ) .Super.onPause ) ;} protected voidonStop ( ) { / / Theactivity is no longer visible ( it is now " ;stopped" super.
onDestroy ;@ Override ( ) ) ;} note: when you override the above function, must first call the parent class of the same method as shown in the example above .The six method covers the activity throughout the life cycle ,override these methods ,you can monitor the activity life cycle in three states :l Activity nested loops in onStart ( visible period ) and onStop ( between ) .
In that period, the user can see the activity and interacting with it .For example :onStop ( ) in the new activity promoter and the current activity is not to be seen to be called .In that period,Coach Outlet Online, you can be maintained in the memory and activity display related resources .
For example :you can onStart ( ) is registered in a BroadcastReceiver ,to monitor the interface influential system event (such as a theme or the font change ) ;and the onStop ( ) in the cancellation of registration ,because the user can not see the activity interface .
During the whole life cycle ,onStart ( ) and onStop ( ) will be called multiple times ,because activity may repeatedly display and hide ,Coach Outlet Store Online,hide and display ... The diagram below shows the circulation as well as in the state when switching activity through steps .
The boxes represent the callback method .The table below for more detailed introduced the life cycle function .Method description completion can be killed? The next onCreate ( ) when activity is created when calling .
This is the general static initialization place ,such as creating the interface ,the data is bound to the list ,etc. .This method will be introduced as a Bundle ,it contains activity on a ( closed ) state ( if the state can be obtained ) .
This method will follow behind onStart ( ) .No onStart onRestart ( ) ( ) is called in to stop after ,Coach Bag Sale,but not stop immediately after the call ,but once again before the start of call ,is also called again onStart ( ) immediately before the call .
No onStart onStart ( ) ( ) when activity becomes visible immediately after the call it .If activity becomes the top, then call the onResume ( ) ,if is completely of cover ,call onStop ( ) .
No onResume ( ) or onStop ( ) onResume ( activity ) when at the top ,this method is called immediately .The activity receives input focus .Followed by onPause ( ) .No onPause onPause ( ) ( ) when another activity to enter the Pause state when this method is called .
This method is generally used to submit those changes to the permanent data ,stop animation and other consumption CPU . .These must be the fastest completion ,because in this method before returning, another activity can not enter the resume state .
When it returned to the top ,followed by onResume ( ) ,Dr Dre Headphones,when it is completely of cover, followed by onStop ( ) .OnResume or onStop onStop ( ) ( ) ( ) when activity is completely of cover to be called .
When activity to destroy or by other activity completely of cover happens .If the activity is back on top, then followed by the onRestart ( ) ,if it passes, with onDestroy ( ) .OnRestart or onDestroy onDestroy ( ) ( ) ( ) in activity destroyed before being called .
This is activity received in the last call .The call may be attributed to others in the activity call finish ( ) ,the system may also be for more memory space and make it the process execution .
Related articles:

没有评论:

发表评论