Project directory: The
manifests main activity tag is placed at the top, and the jump page activity is placed at the back
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test1">
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Main2Activity" />
<activity android:name=".Main3Activity"></activity>
</application>
</manifest>
Main2Activity
package com.example.test1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class Main2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Bundle bundle=this.getIntent().getExtras();
String name=bundle.getString("name");
boolean gent=bundle.getBoolean("gent");
double size=bundle.getDouble("size");
Toast.makeText(this, " "+name+" "+gent+" "+size, Toast.LENGTH_SHORT).show();
}
}
MainActivity
package com.example.test1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btn_jump).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent=new Intent(MainActivity.this,Main2Activity.class);
Bundle bundle=new Bundle();
bundle.putString("name","zzzzz");
bundle.putBoolean("gent",true);
bundle.putDouble("size",18.8);
intent.putExtras(bundle);
startActivity(intent);
}
});
findViewById(R.id.btn_delay_jump).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent=new Intent(MainActivity.this,Main3Activity.class);
startActivity(intent);
}
},2000);
}
});
}
}