I am playing with fragments in Android.
I know I can change a fragment by using the following code:
FragmentManager fragMgr = getSupportFragmentManag
My method is based on try / catch like this :
MyFragment viewer = null; if(getFragmentManager().findFragmentByTag(MY_TAG_FRAGMENT) instanceOf MyFragment){ viewer = (MyFragment) getFragmentManager().findFragmentByTag(MY_TAG_FRAGMENT); }
But there may be a better way ...