环顾四周,我似乎找不到Activity
确定启动resultCode
的方法。例如:
class A extends Activity {
void yadda() {
Intent intent = new Intent(this, B.class);
startActivityForResult(intent, 8675309);
}
}
class B extends Activity {
void yadda() {
int code = getTheResultCode(); // I want to get 8675309
}
}
我是否必须将其放入Intent
?
intent.putExtra("resultCode", 8675309);
答案 0 :(得分:3)
在知道resultCode的Activity中:
Intent i = new Intent(getApplicationContext(), NewActivity.class);
i.putExtra("resultCode",resultCode);
startActivity(i);
在下一个活动中
Bundle extras = getIntent().getExtras();
if (extras != null) {
String resultCode= extras.getString("resultCode");
}