Reputation: 17568
I have activity A that gets passed a long ID value via long extra, when the activity is initially launched. When I go from A-B, and then press home, the ID value is gone. How can I restore it?
When going from A->B
Intent intent = new Intent(A.this, B.class);
startActivity(intent);
I've tried:
Using bundle in onSaveInstanceState
, onRestoreInstanceState
Getting the ID from getIntent
in onResume
getIntent
in onCreate
onCreate
(it's always null,
even when onSaveInstanceState
is called)onFinish
in activity B Explicitly handlingandroid.R.id.home
case in onOptionsItemSelected
in Activity BUpvotes: 0
Views: 131
Reputation: 1105
what is onFinish
in your code?
try this code in your B Activity to get it finish when you press up button in actionbar
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
Upvotes: 3