Question: I was just wondering, can fragment creation only have one instance or singleton?  

I went through *Google iosched* project too. They simply create

```
Fragment a = new Fragment();

```

Whenever they want...

Suppose eg:

```
public static FragmentManager instance;

    public static FragmentManager getInstance() {
        if (instance == null) {
            instance = new FragmentManager();
        }
        return instance;
    }

    public TestFragment getTestFragment() {
        if (testFragment == null) {
            testFragment = new TestFragment ();
        }

        return  testFragment 
    }
}

```

Can I use everywhere 
`FragmentManager.getInstance().getTestFragment()` for transaction?

eg:

```
getSupportFragmentManager()
    .beginTransaction()
    .replace(R.id.content_frame, FragmentManager.getInstance().getTestFragment())
    .commit();

```

Or OS automatically destroy the reference or some issues related to it?

Answer: 
No such limitation. Though, two fragment objects must not have same tag or id.

Also, its good to re-attach an existing fragment, rather that creating a new one.

```
MyFragment f = (MyFragment) getFragmentManager().findFragmenByTag("my_fragment");

if(f == null){
  f = Fragment.instantiate(context, MyFragment.class.getName());
}

if(!f.isAdded()){
  //--do a fragment transaction to add fragment to activity, WITH UNIQUE TAG--
  //--Optionally, add this transaction to back-stack as well--
}

```
If you are trying to make sure that you will not add or replace one or more of your fragments with the same "type" twice or more, then you can use the `FragmentManager.BackStackEntry` to know which of your fragments is currently on the top of the stack.

```
String TAG_FIRST_FRAGMENT = "com.example.name.FIRST.tag";
String TAG_SECOND_FRAGMENT = "com.example.name.SECOND.tag";

FragmentManager fragmentManager = getSupportFragmentManager();
if (fragmentManager.getBackStackEntryCount() == 0 || 
    !fragmentManager.getBackStackEntryAt(
        fragmentManager.getBackStackEntryCount() - 1)
    .getName().equals(TAG_SECOND_FRAGMENT)) {
//Now it's safe to add the secondFragment instance

FragmentTransaction transaction = fragmentManager.beginTransaction();
//Hide the first fragment if you're sure this is the one on top of the stack 
transaction.hide(getSupportFragmentManager().findFragmentByTag(TAG_FIRST_FRAGMENT));
SecondFragment secondFragment = new SecondFragment();
transaction.add(R.id.content_frame, secondFragment, TAG_SECOND_FRAGMENT);
//Add it to back stack so that you can press back once to return to the FirstFragment, and
//to make sure not to add it more than once.
transaction.addToBackStack(TAG_SECOND_FRAGMENT);
transaction.commit();

} 

```