Start a Activity by send extra message

//define this at the top of the first Activity
public final static String EXTRA_MESSAGE="com.binni.AndroidUI.MESSAGE";

//first Activity
Intent intent =new Intent(this,DisplayMessageActivity.class);
EditText edittext=(EditText)findViewById(R.id.edit_message);
String str=edittext.getText().toString();
intent.putExtra(EXTRA_MESSAGE, str);
startActivity(intent);


//second Activity
Intent intent=getIntent();
String str= intent.getStringExtra(AndroidUIActivity.EXTRA_MESSAGE);
TextView textview=(TextView)findViewById(R.id.textview);
textview.setText(str);

  

原文地址:https://www.cnblogs.com/nikyxxx/p/2684014.html