An activity in Android typically requires the implementation of six functions:
OnCreate (), OnStart (), Onresume (), OnPause (), OnStop (), OnDestroy ().
OnCreate function: Register the variables you want to use, such as service,receiver, whether your activity is responsive in the foreground or in the background, and then call the function initialized above to initialize the layout information.
OnStart function: Register some variables. These variables must be available at the front of the Android activity class to be able to respond.
Onresume function: Call some functions that refresh the UI and refresh the state of the UI controls whenever the activity is called here.
OnPause function: The general is to do some variable settings, because this time the activity will be cut to the background processing, may be some variables will be released or the state to do some corresponding adjustment.
OnStop function: Unregister the variable registered in the OnStart function.
Ondestory function: Unregister the variable registered in the OnCreate function.
In the Android-hello,
public class Ubilrnactivity extends Activity {
/** called when the activity is first created. */
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
}
}
First, life has a oncreate function, and the incoming parameter of this function is savedinstancestate. Type is Bundle,bundle is a data parameter, typically used for data transfer between activity. The parameters of OnCreate () are all bundle classes.
Super.oncreate represents a call to the parent class, OnCreate.
Setcontentview (R.layout.main) is the resource that loads the system by loading main.xml.
Android onCreate onStart onresume onPause onStop OnDestroy