WEB开发网
开发学院手机开发Android 开发 Android开发便签:Activity的生命周期 阅读

Android开发便签:Activity的生命周期

 2010-07-01 15:13:00 来源:WEB开发网   
核心提示:public class TestAndroid extends Activity {private static final String TAG = "TestAndroid";@Overridepublic void onCreate(Bundle savedInstanceState) {L

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 {

Tags:Android 开发 便签

编辑录入:coldstar [复制链接] [打 印]
赞助商链接