I have an activity A that launches B with an Intent. (B is a MapActivity and has some async code)
in B i have the following code
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
// Log.d(this.getClass().getName(), "back button pressed");
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
This simply not work. I mean that when I press the back button on the phone, the current activity B disappears and the activity A that launched B is shown.
If I press again on A the button that launch B, I see B is exactly how it was when I closed it. SAME text in textboxes, same Map position… So i think the activity B is not really closed.
How can I close it for real so when I launch again it, activity B is cleas as new born?
EDIT: just to make the question clearer:
I want it to work like this: when the user is on activity B and BACK button is pressed, B has to be closed and destroyed. When the user again launches B from A, B has to be launched as a NEW activity, with blank field, reset map, etc., etc., … just like the first time the user launches B from A.
As i stated in my last comment to the post, @Jianhong given me the correct answer (aslso if as a comment). As he don’t copied the comment as answer in time, i add this answer and mark it as the ACCEPTED. Thanks @Jianhong!
Answer:
@Jianhong OMG! you completely right! i checked for this problem in past days but i couldn’t find it as… i’ve not UPDATED from SVN. my coworker inserted lines of code that prefill fields by some static var!