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
Post a Comment