android - exiting the app when back button is pressed -
i think question has been asked several times,but different scenario.i have 4 activities act1,act2,act3,act4 , had put intends such act1->act2->act3->act4
act1-branch selection,
act2-year selection,
act3-subject selection,
act4-displays selected subject
user can press button act4 moves act3 , can select different subject,similarly when presses button on act3,it moves year selection activity i.e act2.so want 3 activities act1,act2,act3 alive did n't write finish method.i had put home button in act4 leads act1.
when press button in act1 app should close,but forming loop , prevoius activities opened appearing instead.please,provide me solution sorry if question lengthy
you should close activities when coming activity 1 activity 4, following code, using flag intent.flag_activity_clear_top
:
intent = new intent(activity4.this, activity1.class); it.addflags(intent.flag_activity_clear_top); startactivity(it);
so in activity 1 when press button, finish app.
hope helps!
Comments
Post a Comment