在被打开的活动中添加方法
public class SecondActivity extends AppCompatActivity {
public static void actionStart(Context context,String data1,String data2){
Intent intent = new Intent(context,SecondActivity.class);
intent.putExtra("param1",data1);
intent.putExtra("param2",data2);
context.startActivitiy(intent);
}
//...
}
在FirstActivity中只需一行代码即可
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SecondActivity.actionStart(FirstACtivity.this,"data1","data2");
}
});