*(1)AndroidMainfest.xml配置文件**
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cn.edu.bzu.activitydemo"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".FirstActivity"
android:launchMode="standard">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"
android:launchMode="singleInstance"/>
<activity android:name=".ThirdActivity">
</activity> </application></manifest>
**```**(2)activity_first.xml**
package cn.edu.bzu.activitydemo;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.Toast;public class FirstActivity extends AppCompatActivity { private Button btnClick; @Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
Log.d("FirstActivity", this.toString());
btnClick = (Button) findViewById(R.id.btnClick);
btnClick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(FirstActivity.this, SecondActivity.class); startActivity(intent);
}
});
}
protected void onStart() { super.onStart(); Log.d("FirstActivity", "onStart"); } protected void onResume() { super.onResume(); Log.d("FirstActivity", "onResume"); } protected void onPause() { super.onPause(); Log.d("FirstActivity", "onPause"); } protected void onStop() { super.onStop(); Log.d("FirstActivity", "onStop"); }}(3)activity_second.xml
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="cn.edu.bzu.activitydemo.SecondActivity">
<TextView android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
tools:layout_editor_absoluteX="162dp"
tools:layout_editor_absoluteY="132dp" />
</android.support.constraint.ConstraintLayout>
4)layout中三个activity的三个布局文件activity_main.xml(这里演示一个,其余两个只是下面TextView文字不一样)