在Android的活动之间传递数据

问题描述:

你如何通过在Android应用程序活动之间的数据?

How do you pass data between activities in an Android application?

在你当前活动,创建一个意图

in your current activity, create an intent

Intent i = new Intent(getApplicationContext(), ActivityB.class);
i.putExtra(key, value);
startActivity(i);

然后在其他活动中,检索这些值。

then in the other activity, retrieve those values.

Bundle extras = getIntent().getExtras(); 
if(extras !=null) {
    String value = extras.getString(key);
}