How to set target fragment of a dialog when using navigation components : <p>I'm showing a dialog inside a fragment using <code>childFragmentManager</code> or within an Activity using the <code>supportFragmentManager</code>, in the process I would like to set the target fragment, like this:</p>

<pre><code>val textSearchDialog = TextSearchDialogFragment.newInstance()
textSearchDialog.setTargetFragment(PlaceSearchFragment@this, 0)
</code></pre>

<p>But when running that code I get the error:</p>

<blockquote>
  <p>java.lang.IllegalStateException: Fragment
  TextSearchDialogFragment{b7fce67 #0 0} declared target fragment
  PlaceSearchFragment{f87414 #0 id=0x7f080078} that does not belong to
  this FragmentManager!</p>
</blockquote>

<p>I don't know how to access the <code>FragmentManager</code> the navigation components are using to manage the showing of the fragment, is there a solution for this?</p>
