import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.util.Log;
public class MainActivity extends Activity {
private static String TAG = "LIFTCYCLE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG, ("(1)onCreate()"));
}
public void onStart()
{
super.onStart();
Log.i(TAG, "(2)onStart()");
}
public void onRestoreInstanceState(Bundle savedInstanceState){
super.onRestoreInstanceState(savedInstanceState);
Log.i(TAG, "(3)onRestoreInstanceState()");
}
public void onResume()
{
super.onResume();
Log.i(TAG, "(4)onResume()");
}
public void onSaveInstanceState(Bundle saveInstanceState){
super.onSaveInstanceState(saveInstanceState);
Log.i(TAG, "(5)onSaveInstanceState");
}
public void onRestart()
{
super.onRestart();
Log.i(TAG, "(6)onRestart()");
}
public void onPause()
{
super.onPause();
Log.i(TAG, "(7)onPause()");
}
public void onStop()
{
super.onStop();
Log.i(TAG, "(8)onStop");
}
public void onDestroy()
{
super.onDestroy();
Log.i(TAG, "(9)onDestory");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Android生命周期
最新推荐文章于 2023-12-26 10:48:34 发布