Android开发便签:Activity的生命周期
2010-07-01 15:13:00 来源:WEB开发网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();
}
}
通过在DDMS中查看日志信息:
Java代码
06-28 02:14:08.760: INFO/TestAndroid(220): =======onCreate()========
06-28 02:14:09.005: INFO/TestAndroid(220): =======onStart()========
06-28 02:14:09.005: INFO/TestAndroid(220): =======onResume()========
06-28 02:14:09.321: INFO/ActivityManager(53): Displayed activity com.andy.android/.TestAndroid: 1687 ms (total 1687 ms)
06-28 02:14:09.641: ERROR/gralloc(53): [unregister] handle 0x497218 still locked (state=40000001)
06-28 02:14:16.840: INFO/ActivityManager(53): Starting activity: Intent {
更多精彩
赞助商链接