How to get a Fragment to remove itself, i.e. its equivalent of finish()?
<p>I'm converting an app to use fragments using the compatibility library.
Now currently I have a number of activities (A B C D) which chain onto one another, D has a button 'OK' which when pressed calls finish which then bubbles up through onActivityResult to additionally destroy C and B.</p>

<p>For my pre Honycomb fragment version each activity is effectively a wrapper on fragments Af Bf Cf Df. All activities are launched via startActivityForResult and onActivityResult within each of the fragments can happily call getActivity().finish</p>

<p>The problem that I am having though is in my Honeycomb version I only have one activity, A, and fragments Bf, Cf, Df are loaded using the FragmentManager.</p>

<p>What I don't understand is what to do in Df when 'OK' is pressed in order to remove fragments Df, Cf, and Bf? </p>

<p>I tried having the fragment popping itself off the stack but this resulted in an exception. onActivityResult is useless because I have not loaded up the fragment using startActivityForResult.</p>

<p>Am I thinking about this completely the wrong way? Should I be implementing some sort of listener that communicates with either the parent fragment or activity in order to do the pop using the transaction manager?</p>

<p>Thanks in advance. Peter. </p>
