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: 
When you use `getSupportFragmentManager().beginTransaction().replace` you can add a third parameter as a string that you can use as a tag, so in case you want to recover a previous fragment you can use `getSupportFragmentManager().findFragmentByTag(String)` so you won't have to create a new fragment.

So it would be like this

Check if the fragment exists using `findFragmentByTag(String)` if it not exists, create a new fragment and call `getSupportFragmentManager().beginTransaction() .replace(R.id.content_frame,myFragment,myTag).commit();` where myTag is the String you'll use in your findFragmentByTag. This way you won't create more than one fragment of every type.

I hope it makes some sense :)

For more information check [this](http://developer.android.com/reference/android/app/FragmentTransaction.html#replace%28int,%20android.app.Fragment,%20java.lang.String%29) and [this](http://developer.android.com/reference/android/app/FragmentManager.html#findFragmentByTag%28java.lang.String%29)
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();

} 

```