In your current Activity, create a new Intent
:
(在您当前的活动中,创建一个新的Intent
:)
String value="Hello world";
Intent i = new Intent(CurrentActivity.this, NewActivity.class);
i.putExtra("key",value);
startActivity(i);
Then in the new Activity, retrieve those values:
(然后在新的活动中,检索以下值:)
Bundle extras = getIntent().getExtras();
if (extras != null) {
String value = extras.getString("key");
//The key argument here must match that used in the other activity
}
Use this technique to pass variables from one Activity to the other.
(使用此技术将变量从一个活动传递到另一个活动。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…