android activty的生命周期

阅读更多

app1 activty 中点击按钮后进入 app2 activty

 

在每个activty的生命周期的有代表性的方法里加了log,输出如下:

 

 

09-02 16:18:52.515: DEBUG/dalvikvm(637): GC freed 1158 objects / 56288 bytes in 81ms
09-02 16:18:55.793: WARN/KeyCharacterMap(637): No keyboard for id 0
09-02 16:18:55.793: WARN/KeyCharacterMap(637): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-02 16:19:10.753: INFO/ActivityManager(570): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x10200000 comp={www.wangping.net/www.wangping.net.app1} }
09-02 16:19:10.864: INFO/ActivityManager(570): Start proc www.wangping.net for activity www.wangping.net/.app1: pid=907 uid=10020 gids={}
09-02 16:19:11.004: INFO/jdwp(907): received file descriptor 10 from ADB
09-02 16:19:11.315: DEBUG/app1(907): onCreate  刚刚进入程序 app1 create
09-02 16:19:11.364: DEBUG/app1(907): onStart   刚刚进入程序 app1 start
09-02 16:19:11.373: DEBUG/app1(907): onResume  刚刚进入程序 app1 onResume  这时 app1 显示在屏幕上了.
09-02 16:19:11.583: INFO/ActivityManager(570): Displayed activity www.wangping.net/.app1: 827 ms
09-02 16:19:16.675: DEBUG/dalvikvm(637): GC freed 700 objects / 33168 bytes in 81ms
09-02 16:19:26.765: DEBUG/dalvikvm(570): GC freed 10687 objects / 544464 bytes in 127ms
09-02 16:19:27.084: WARN/KeyCharacterMap(907): No keyboard for id 0
09-02 16:19:27.084: WARN/KeyCharacterMap(907): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-02 16:19:29.314: INFO/ActivityManager(570): Starting activity: Intent { comp={www.wangping.net/www.wangping.net.app2} (has extras) }
09-02 16:19:29.355: DEBUG/app1(907): onPause    用户点击按钮进入app2了, 先停app1 把app1放入堆栈
09-02 16:19:29.394: DEBUG/app2(907): onCreate   再creae app2
09-02 16:19:29.413: DEBUG/app2(907): 123    运行app2 里的onCreate
09-02 16:19:29.413: DEBUG/app2(907): sssssHello World, app1!   运行app2 里的onCreate
09-02 16:19:29.413: DEBUG/app2(907): onStart    app2 onstart了
09-02 16:19:29.413: DEBUG/app2(907): onResume   app2 己经显示在屏幕上了.
09-02 16:19:29.515: INFO/ActivityManager(570): Displayed activity www.wangping.net/.app2: 205 ms
09-02 16:19:29.555: DEBUG/app1(907): onStop     将堆栈中的app1设为stop,表示暂时不会再用它了.
09-02 16:20:11.885: DEBUG/app2(907): onPause    用户点击返回按钮,要返回app1 先停app2
09-02 16:20:11.904: DEBUG/app1(907): onRestart  因为app1被stop 了,所以要先restart
09-02 16:20:11.904: DEBUG/app1(907): onStart    app1 再onstart 再从新start 一次.
09-02 16:20:11.904: DEBUG/app1(907): onResume   app1显示
09-02 16:20:12.033: DEBUG/app2(907): onStop    再停app2
09-02 16:20:12.033: DEBUG/app2(907): onDestroy  app2并没有入栈,所以直接销毁了。

你可能感兴趣的:(Android,.net)