Reputation: 359
The parameters of a method is used to pass some data I guess. But I'm just confused how it is working over here in this example.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data == null) {
return;
}
mIsCheater = data.getBooleanExtra(CheatActivity.EXTRA_ANSWER_SHOWN, false);
}
PS: I'm a newbie. Started learning Android from a book just few days back.
Upvotes: 1
Views: 1927
Reputation: 9261
your activity may have multiple intents that each call different activities. The request code is to differentiate between those different intents. Why? The method itself is a call back, when the finish() method is called in the activity that this activity triggered with a startActivityForResult(), this method will be triggered. The intent therefore is the intent used to call back to this activity. result code tells you if the request that you got back was ok or not.
Upvotes: 2