Android开发便签:Activity的生命周期
2010-07-01 15:13:00 来源:WEB开发网关于Android Activity生命周期的例子
Java代码
package com.andy.android;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
/**
* 测试Android Activity 生命周期
* @author Andy.Zhang
*
*/
public class TestAndroid extends Activity {
private static final String TAG = "TestAndroid";
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "=======onCreate()========");
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected void onDestroy()
{
Log.i(TAG, "=======onDestroy()========");
super.onDestroy();
}
@Override
protected void onPause()
{
Log.i(TAG, "=======onPause()========");
super.onPause();
}
@Override
protected void onRestart()
{
Log.i(TAG, "=======onRestart()========");
super.onRestart();
}
@Override
protected void onResume()
{
Log.i(TAG, "=======onResume()========");
super.onResume();
}
@Override
protected void onStart()
{
Log.i(TAG, "=======onStart()========");
super.onStart();
}
@Override
protected void onStop()
{
Log.i(TAG, "=======onStop()========");
super.onStop();
}
}
package com.andy.android;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
/**
* 测试Android Activity 生命周期
* @author Andy.Zhang
*
*/
更多精彩
赞助商链接