recyclerview - Android back-button working but back via home button not working perfectly -


i have recycler view data. when item clicked, opens new detailsactivity. trouble when come detailsactivity mainactivity back-button (down on natel) working perfectly. when come via home button extends actionbaractivity, load data again scratch. want same return button in natel below. have idea?

back code in onoptionsitemselected methord:

if (id == android.r.id.home) { intent homeintent = new intent(this, activitymain.class); homeintent.addflags(intent.flag_activity_clear_top); startactivity(homeintent);  // navutils.navigateupfromsametask(this); // tried } 

if understood correctly, instead of starting activity over, call finish() on current activity.

basically when click item calling below correct (or along lines)?

startactivity(new intent(this, detailsactivity.class); 

if so, once in detailsactivity, call:

if (id == android.r.id.home) {     finish(); } 

that finish detailsactivity shown on mainactivity , return exact same spot at.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -