Activity LifeCycle (安卓应用的运行机制)

 

 

测试回调代码

package com.example.hello;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {
    String TAG="myTag";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.d(TAG,  "on Create:");
    }
    @Override
    protected void onStart(){
        super.onStart();
        Log.d(TAG,"on Start:");
    }
    @Override
    protected void onResume(){
        super.onResume();
        Log.d(TAG,"on Resume:");
    }

    @Override
    protected void onResumeFragments() {
        super.onResumeFragments();
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d(TAG,"on Pause:");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d(TAG,"on Stop:");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d(TAG,"on Restart:");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d(TAG,"on Destroy:");
    }
}
MainActivity

 

测试结果

 

posted @ 2020-01-30 20:07  你的深渊  阅读(205)  评论(0编辑  收藏  举报