3.18

所花时间(包括上课):1

打码量(行):200

博客量(篇):1

了解到知识点:学习activity的启动与结束,生命周期,启动模式

import android.content.Intent;

import android.os.Bundle;

import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

 

public class MainActivity extends AppCompatActivity {

 

    private static final String TAG = "MainActivity";

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        Log.d(TAG, "onCreate");

    }

 

    @Override

    protected void onStart() {

        super.onStart();

        Log.d(TAG, "onStart");

    }

 

    @Override

    protected void onResume() {

        super.onResume();

        Log.d(TAG, "onResume");

    }

 

    @Override

    protected void onPause() {

        super.onPause();

        Log.d(TAG, "onPause");

    }

 

    @Override

    protected void onStop() {

        super.onStop();

        Log.d(TAG, "onStop");

    }

 

    @Override

    protected void onDestroy() {

        super.onDestroy();

        Log.d(TAG, "onDestroy");

    }

 

    public void startSecondActivity(View view) {

        Intent intent = new Intent(this, SecondActivity.class);

        startActivity(intent);

    }

}

import android.os.Bundle;

import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

 

public class SecondActivity extends AppCompatActivity {

 

    private static final String TAG = "SecondActivity";

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_second);

        Log.d(TAG, "onCreate");

    }

 

    @Override

    protected void onStart() {

        super.onStart();

        Log.d(TAG, "onStart");

    }

 

    @Override

    protected void onResume() {

        super.onResume();

        Log.d(TAG, "onResume");

    }

 

    @Override

    protected void onPause() {

        super.onPause();

        Log.d(TAG, "onPause");

    }

 

    @Override

    protected void onStop() {

        super.onStop();

        Log.d(TAG, "onStop");

    }

 

    @Override

    protected void onDestroy() {

        super.onDestroy();

        Log.d(TAG, "onDestroy");

    }

}

posted @ 2024-03-18 19:39  赵千万  阅读(4)  评论(0编辑  收藏  举报