Back Button closes the Application in Android -


i have application.suppose there 3 activities a,b,c.

a->b(sub-activity)->c(sub-activity).

i have set these kind code switch next activity.

 setcontentview(r.layout.b); 

and problem when click button on emulator or phone while on activity b or c,closes application window come home. want if press button on activity c firstly move activity b , a,afterwards if i'll click again button comes home-screen or closes application window.

any methods or wrong in code or have edit ?

you can override default press , tell reset content view have keep track of stack yourself.

@override public boolean onkeydown(int keycode, keyevent event) {     if (keycode == keyevent.keycode_back) {         //code reset view         return true;     }     return super.onkeydown(keycode, event); } 

this said recommend @ allow android handle stack in default manner. method end causing headaches in future.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -