FragmentActivity: Cannot cast from Fragment to derived class
You are extending the wrong Fragment class. Import android.support.v4.app.Fragment
instead of android.app.Fragment
.
As devconsole pointed out in the comment above: The class that extends Fragment needs to import
android.support.v4.app.Fragment;
and not
android.app.Fragment;
I guess it has to do with the Android Compatibility Package. Problem is now resolved!
Just in case people are looking for kotlin equivalent:
myFragmentClass = supportFragmentManager.findFragmentById(R.id.my_fragment) as MyFindOfFragment