When calling another activity, can I be sure that the variable I store in the current activity will be present when it returns?
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View item, int pos, long id) {
Intent i = new Intent(Activity1.this, Activity2.class);
i.putExtra("position", pos); // 1
position = pos; // 2
startActivityForResult(i, REQUEST_CODE); // brings up the edit item activity
}
});
For the code above, can I use (2) by storing in current activity instance field or should I pass the value using (1) then use getIntExtra()
in onActivityResult()
to recover that value?