Listener registration not working in fragment to D...
# android
a
Listener registration not working in fragment to Dialog fragment communication. Am I missing anything for registration ?
Copy code
override fun onAttach(context: Context) {
    AndroidSupportInjection.inject(this)
    super.onAttach(context)
    if (context is Listener) {
      listener = context
    }
  }

  override fun onDetach() {
    super.onDetach()
    listener = null
  }
d
I don't think that's how you pass a listener to a fragment...
a
I've been solved this issue in this way
Copy code
override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  listener=
    parentFragment?.childFragmentManager?.primaryNavigationFragment.cast<Listner>()
}

override fun onDestroy() {
  super.onDestroy()
  listener= null
}
d
That's not how Google recommends either, but it's your app :)
a
Basically I have been tried different ways even you suggested one but no luck. Only the above solutions working perfectly. Thanks for your input. Fragment to DialogFragemnt target set not register at all and that's why I have been implemented this solution.