When you add the fragment to your transaction add a tag,
fragmentTransaction.replace(android.R.id.container, homeFragment, "HOME_FRAGMENT");
After that, to check if fragment is currently displayed is easy :
HomeFragment homeFragment = (HomeFragment)getFragmentManager().findFragmentByTag("HOME_FRAGMENT");
if (homeFragment != null && homeFragment.isVisible()) {
// do whatever you want :)
}
您可以使用应用程序的软件包名称浏览Logcat,然后通常会有一些相关的调用,例如onActivityDestroyed
,从中可以看到需要处理的片段