Reputation: 1727
I have a non-UI persistant fragment to keep track of bluetooth devices in my app (so all pairings aren't lost as soon as the user turns the phone).
I now need to access the data in this fragment from several activites and other fragments. Suffice to say it's not an option to create a new instance of the fragment for each activity, it must be the same instance in all of them. Is this allowed or even possible? What would happen with the fragments' onDetach function?
Upvotes: 0
Views: 294
Reputation: 61
From google developers: "A fragment must always be embedded in an activity and the fragment's lifecycle is directly affected by the host activity's lifecycle. For example, when the activity is paused, so are all fragments in it, and when the activity is destroyed, so are all fragments."
Meaning it's not possible..
Upvotes: 1