Intent i = new Intent(getApplicationContext(), NewActivity.class);
i.putExtra("new_variable_name","value");
startActivity(i);
Bundle extras = getIntent().getExtras();
if (extras != null) {
String value = extras.getString("new_variable_name");
}
我的情况有点不同:我的主要活动调用了另一个(索引活动):
Intent index = new Intent(this, Index.class);
startActivity(index);
从索引活动中,用户可以从列表中进行选择。
所以,我需要将索引的类变量传递给主要活动。如何?
谢谢!