What is wrong with doing what you propose is that the data will be lost on a configuration change. The arguments Bundle
is automatically part of the saved instance state of the fragment, and so that data will automatically be retained on a configuration change. Otherwise, by default, you would lose your page number when the user rotates the screen or does any other configuration change.
There are other ways that you could address the problem (e.g., put the page number in the onSavedInstanceState()
Bundle
yourself). The factory method and arguments Bundle
is just a simple and effective way of addressing the issue, but it is not the only way.