用到不同方法时候某些系统有不太一样的情况:
public class MainActivity extends Activity { private static String TAG = "MainActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.i(TAG, "onCreate"); } @Override protected void onStart() { // TODO Auto-generated method stub super.onStart(); Log.i(TAG, "onStart"); } @Override protected void onRestart() { // TODO Auto-generated method stub super.onRestart(); Log.i(TAG, "onRestart"); } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); Log.i(TAG, "onResume"); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); Log.i(TAG, "onPause"); } @Override protected void onStop() { // TODO Auto-generated method stub super.onStop(); Log.i(TAG, "onStop"); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); Log.i(TAG, "onDestroy"); } @Override protected void onSaveInstanceState(Bundle outState) { // TODO Auto-generated method stub super.onSaveInstanceState(outState); Log.i(TAG, "onSaveInstanceState"); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onRestoreInstanceState(savedInstanceState); Log.i(TAG, "onRestoreInstanceState"); } @Override protected void onNewIntent(Intent intent) { // TODO Auto-generated method stub super.onNewIntent(intent); Log.i(TAG, "onNewIntent"); } @Override protected void onUserLeaveHint() { // TODO Auto-generated method stub super.onUserLeaveHint(); Log.i(TAG, "onUserLeaveHint"); } }
1.note2和盖世2:启动流程部分不同。红色标出
10-25 21:24:58.990: I/MainActivity(17527): onCreate
10-25 21:24:58.990: I/MainActivity(17527): onStart
10-25 21:24:58.995: I/MainActivity(17527): onResume
主界面按返回键:
10-25 21:25:25.290: I/MainActivity(17527): onPause
10-25 21:25:25.485: I/MainActivity(17527): onStop
10-25 21:25:25.485: I/MainActivity(17527): onDestroy
主界面按menu键
10-25 21:26:05.650: I/MainActivity(17527): onUserLeaveHint
10-25 21:26:05.650: I/MainActivity(17527): onPause
10-25 21:26:06.800: I/MainActivity(17527): onSaveInstanceState
10-25 21:26:06.800: I/MainActivity(17527): onStop
再进入:
10-25 21:27:13.050: I/MainActivity(17527): onRestart
10-25 21:27:13.050: I/MainActivity(17527): onStart
10-25 21:27:13.050: I/MainActivity(17527): onResume
按电源键:
10-25 21:27:43.355: I/MainActivity(17527): onPause
10-25 21:27:43.360: I/MainActivity(17527): onSaveInstanceState
10-25 21:27:43.360: I/MainActivity(17527): onStop
再进入主界面
10-25 21:28:06.895: I/MainActivity(17527): onRestart
10-25 21:28:06.895: I/MainActivity(17527): onStart
10-25 21:28:06.895: I/MainActivity(17527): onResume
以下是不同之处:
note2:
在主界面突然来电
10-25 21:28:55.285: I/MainActivity(17527): onPause
挂断电话结束返回主界面:
10-25 21:29:48.090: I/MainActivity(17527): onResume
盖世2:
在主界面突然来电
10-25 21:36:57.295: I/MainActivity(5634): onUserLeaveHint
10-25 21:36:57.295: I/MainActivity(5634): onPause
10-25 21:36:57.450: I/MainActivity(5634): onSaveInstanceState
挂断后返回:
10-25 21:36:59.020: I/MainActivity(5634): onResume
可能是刷的系统导致的不同,来电界面note2上估计是弹出的全屏toast,盖世2的系统可能是从底部冒出的其它半覆盖view所致。
原文地址:http://blog.csdn.net/proheart/article/details/40457139