android - How do you use Intent.FLAG_ACTIVITY_CLEAR_TOP to clear the Activity Stack? -
i've read through several posts using this, must missing it's not working me. activity has launchmode="singletop" in manifest. starts activity b, launchmode="singleinstance". activity b opens browser , receives , intent back, why it's singleinstance. i'm trying override button user sent activity a, , can press leave activity, rather activity b again.
// activity b @override public boolean onkeydown(int keycode, keyevent event) { if (android.os.build.version.sdk_int < android.os.build.version_codes.eclair && keycode == keyevent.keycode_back && event.getrepeatcount() == 0) onbackpressed(); return super.onkeydown(keycode, event); } @override public void onbackpressed() { startactivity(new intent(this, ui.class) .setflags(intent.flag_activity_clear_top | intent.flag_activity_new_task)); return; } after returning browser, stack is... a,b,browser,b
i expect code change stack to... ... pressing once more takes user home screen.
instead seems change stack to... a,b,browser,b,a ...as though flags aren't there.
i tried calling finish() in activity b after startactivity, button takes me browser again!
what missing? thank you!
@bitestar has correct solution, there 1 more step:
it hidden away in docs, must change launchmode of activity other standard. otherwise destroyed , recreated instead of being reset top.
Comments
Post a Comment