2011年3月7日 星期一

[Android] Activity執行(啟動)另一個Activity 之 life cycle分析

先前的文章-

[Android] Activity執行(啟動)另一個Activity


這樣子的啟動方式
是真的去new一個新的Activity

所以lifecycle順序會是
1(CheckAndroidLifeCycle)呼叫2(OtherActivity)


01-01 04:03:41.691: INFO/ActivityManager(2134): Starting activity: Intent { cmp=application.nelson/.OtherActivity }
01-01 04:03:41.701: VERBOSE/1(29115): onPause
01-01 04:03:41.721: WARN/Resources(29115): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f050000}
01-01 04:03:41.721: VERBOSE/2(29115): onCreate
01-01 04:03:41.721: VERBOSE/2(29115): onStart
01-01 04:03:41.721: VERBOSE/2(29115): onResume
01-01 04:03:42.001: INFO/ActivityManager(2134): Displayed activity application.nelson/.OtherActivity: 293 ms (total 293 ms)
01-01 04:03:42.001: VERBOSE/1(29115): onStop

2
01-01 04:03:44.261: VERBOSE/2(29115): onPause
01-01 04:03:44.261: INFO/ActivityManager(2134): Starting activity: Intent { cmp=application.nelson/.CheckAndroidLifeCycle }
01-01 04:03:44.281: WARN/Resources(29115): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f050000}
01-01 04:03:44.281: VERBOSE/1(29115): onCreate
01-01 04:03:44.281: VERBOSE/1(29115): onStart
01-01 04:03:44.281: VERBOSE/1(29115): onResume
01-01 04:03:44.541: INFO/ActivityManager(2134): Displayed activity application.nelson/.CheckAndroidLifeCycle: 272 ms (total 272 ms)
01-01 04:03:44.541: VERBOSE/2(29115): onStop


Source code download


有沒有方法是可以讓activity life cycle像下面圖片呢
onPause->onResume(不要有onCreate)

Reference:
http://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent)
http://developer.android.com/reference/android/app/Activity.html


透過Facebook分享

沒有留言: