putExtraメソッドについて。keyとか。hashmapっぽく。

遷移元のActivityでは以下のように書きます。

Intent intent = new Intent(this, ToActivity.class);
intent.putExtra(“key1″, “hogehogeValue”);
intent.putExtra(“key2″, “hogehogeValue2″);
startActivityForResult(intent, 0);

続いて遷移先ActivityのonCreate()メソッド内のプログラムです。

String sKey1 = “”;
String sKey2 = “”;
Bundle extras=getIntent().getExtras();
if (extras!=null) {
sKey1 = extras.getString(“key1″);
sKey2 = extras.getString(“key2″);
}