Thursday, 15 August 2013

Best practice for updating arguments of a fragment?

Best practice for updating arguments of a fragment?

I know about the "newInstance"-Pattern (Best practice for instantiating a
new Android Fragment). But how do I update these arguments of a fragment
for example if another fragment changes data?
I know about callback-methods between Fragments/Activitys, but these
callbacks won't update the arguments?!
For example: on creation of the fragment I pass an URI to the it with the
bundle. Then another fragment changes this URI via changeUri(Uri uri)
method callback on the first fragment. If then the fragment gets recreated
(for example due to screen rotation) it will use the first URI from the
arguments bundle instead of the later updated uri, correct?
What is the best practice to solve this? Do I have to manually store it in
the savedInstanceState and on usage decide whether to use the
instanceState or arguments-bundle?

No comments:

Post a Comment