Shouldn't hitting BACK from C take you to the original B? So the stack should look like:
A>
B>
C<
B>
C>
C<
C<
B<
A
with > going to the next activity, and < being the back button?
You could override onBackPressed for all the activities, so for C it loads a new B, B it loads a new A, and A you would do moveTaskToBack(true);
, but that's less of a solution and more of a hack to make it work.
Try to use onResume so that B comes up like it would on default. Set any pertinent variables to what they are in a new activity. If you only want this when you're coming from C, have a class boolean that is set to true when C is loaded, and check it in onResume or onRestart. If it's true, set everything to default/blank, and set the boolean to false. If not, load it how it was (this is if they hit home and come back to the app, basically). I'm not at my work desk, but I think you'll want:
@Override
public void onResume() {
super.onResume();
if(fromC == true){
//Set all variables to load default dictionary
fromC = false;
}
}
}
This should make the original B act like a new B.
Or instead, you could do it the easy way, and when you call the intent to load a new B like this:
startActivity(getIntent());
finish();
That'll make there only be one B. Making it load as a blank when you go back is a little bit different and requires class variables, or some other tricky trick that I am thinking of. This is something like what you'll want to do: .zip of small sample
If you can get your code reworked to something like that almost (where you can use the appropriate variables to set up things to work right if that makes any sense).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…