why “onPause” is not called in following situation?

后端 未结 5 1133

By the document, \"onPause\" is called, when:

when the system is about to start resuming a previous activity.

Compared to \"onSt

5条回答
  •  梦谈多话
    2021-01-13 03:31

    public class MainActivity extends Activity
    {
        String tag="my result";
    
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            Log.v(tag,"I am in oncreate");
        }
    
        @Override
        protected void onDestroy() {
            // TODO Auto-generated method stub
            super.onDestroy();
            Log.v(tag,"I am in onDestroy");
        }
    
        @Override
        protected void onPause() {
            // TODO Auto-generated method stub
            super.onPause();
            Log.v(tag,"I am in onpause");
        }
    
        @Override
        protected void onRestart() {
            // TODO Auto-generated method stub
            super.onRestart();
            Log.v(tag,"I am in onRestart");
        }
    
        @Override
        protected void onResume() {
            // TODO Auto-generated method stub
            super.onResume();
            Log.v(tag,"I am in onresume");
        }
    
        @Override
        protected void onStart() {
            // TODO Auto-generated method stub
            super.onStart();
            Log.v(tag,"I am in onstart");
        }
    
        @Override
        protected void onStop() {
            // TODO Auto-generated method stub
            super.onStop();
            Log.v(tag,"I am in onstop");
        }
    }
    

    Run it and check logcat.press back button and then check.after again start application and

    Press call button then check logcat now press Back button and again check logcat. you can easily understand life cycle of Activity.

提交回复
热议问题