android - Activity flow issues on a multi-step wizard -


i have 5-step informational wizard , next buttons, each step activity. problem when user taps button on activity (not button of phone) taps next again, order of activities being messed bit. seen when user presses physical button on phone.

example:

(1)(next) -> (2)(next) -> (3)(back) -> (2)(next) -> (3)(next) -> (4)

now when user presses key on phone repeatedly step 4, activities shown in following order:

4 - 3 - 2 - 3 - 2 - 1

instead of

4 - 3 - 2 - 1

here's code 3rd screen:

public class step3activity extends activity {     button buttonnext, buttonback;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          buttonnext = (button) findviewbyid(r.id.buttonnext);         buttonback = (button) findviewbyid(r.id.buttonback);          buttonnext.setonclicklistener(new onclicklistener(){             @override             public void onclick(view v) {                 next();             }         });         buttonback.setonclicklistener(new onclicklistener(){             @override             public void onclick(view v) {                 back();             }         });     }      private void next() {         intent intent = new intent(this, step4activity.class);         startactivity(intent);     }      private void back() {         intent intent = new intent(this, step2activity.class);         startactivity(intent);     } } 

i don't see errors think may in code.

the problem back() method starts instance of previous activity. can call finish() on current activity , automatically go previous activity if don't need pass data back.

    private void back() {         finish();     } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -