getSupportFragmentManager() versus getFragmentManager() in android 3.0+

后端 未结 3 452
半阙折子戏
半阙折子戏 2020-12-18 00:18

In the documentation for android.support.v4.app.FragmentManager:

\"Static library support version of the framework\'s FragmentManager. Used to write apps that run on

相关标签:
3条回答
  • 2020-12-18 00:57

    If you are using support Packages in your project or app, then you have to use getSupportFragmentManager because that is how you will return the fragmentManager for interacting with fragments associated with this activity. In the other hand, if you are not, then you can use getFragmentManager. It only depends on what you are using in your app.

    0 讨论(0)
  • 2020-12-18 00:58

    If you are using API >= 14, then use getFragmentManager(). If you want compatibility with devices below API 14 then you can use getSupportFragmentManager(). Therefore, getSupportFragmentManager() is used to deliver newer features to older platforms.

    0 讨论(0)
  • 2020-12-18 01:00

    There's nothing wrong with using getSupportFragmentManager() on Android 3.0+ as long as you have the support library imported. If you want to use getFragmentManager() for SDKs 11+, go for it; just keep in mind that you may be if/elseing a lot of code with version checks.

    0 讨论(0)
提交回复
热议问题