instantiate()
allows you to specify a fragment by name, without compile-time static resolution of the class.
It's useful when the fragment name comes from some runtime source, such as a binary XML:
This is how the framework instantiates fragments specified in layout XML.
In code, it's preferable to use newInstance()
or the empty constructor to get compile-time static type checking.
The code instantiate() does under the hood is not too different from what happens when instantiated with newInstance()
/ empty constructor so there's unlikely to be a significant difference in performance.