About creating new Intent in android -


i practising android development. created button in main activity opens second activity:

i use code button:

 this.detailsbtn = (button) findviewbyid(r.id.details_btn);     this.detailsbtn.setonclicklistener(new onclicklistener() {          @override         public void onclick(view arg0) {             intent k = new intent(arg0.getcontext(), detailsactivity.class);              startactivity(k);         }     }); 

this code works opens second activity. added button leads main activity in detailsactivity.

this.mainlistbtn = (button) findviewbyid(r.id.main_list_btn);     this.mainlistbtn.setonclicklistener(new onclicklistener() {          @override         public void onclick(view arg0) {             intent k = new intent(arg0.getcontext(), mainactivity.class);              startactivity(k);         }     }); 

this works properly. question should create new intent each time press whatever of buttons looks needs time open new activity?

is there way access intent created instead of recreating it?

only call finish() detailsactivity

this.mainlistbtn = (button) findviewbyid(r.id.main_list_btn);     this.mainlistbtn.setonclicklistener(new onclicklistener() {          @override         public void onclick(view arg0) {            finish();         }     }); 

this works properly. question should create new intent each time press whatever of buttons looks needs time open new activity?

you current application works fine, agreed. happen is, new activity added application stack on each time when button pressed. should not happen in case.


Comments