Is there a way to remove all fragments which already added the specific view with its view id?
For example I want to remove all fragments which is added R.id.fragmentcon
Use this code
activity?.let { it.supportFragmentManager.fragments.forEach { fragment -> it.supportFragmentManager.beginTransaction().remove(fragment).commit() } }
Hope it helps.
Thank you.