How to close the activity from current fragment and go back to previous activity in android? -


i having multiple activity in android app multiple fragment each activity. fragment of third activity, want close third activity on press. have tried using inside ondetach() function.

getactivity().finish(); 

this closes current activity while opening same activity again, app crashes.

finish() final call before activity gets garbage collected.

you should either not call @ since there's no real reason so. if want return later, can't. can create new activity. fragments, happens on parent happens on fragment too.

if want close specific activity, have keep reference somewhere fragment can access it. preferably wrapped in weakreference won't leak memory.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -