Kotlin
val fragmentManager: Fragment? = this@MainActivity.fragmentManager.findFragmentById(R.id.flSetContent)
//R.id.flSetContent就是我们Activity里面用于添加Fragment的底层布局ID
if (fragmentManager != null && fragmentManager is CommonFragment) {
Log.e("testFragment", " 当前是CommonFragment")
} else {
Log.e("testFragment", " 当前不是CommonFragment")
}
//is相当于 JAVA中的 instanceof