First, I'd to state that I've been searching for a solution for this problem for three days now, that may means either I'm not asking the right question or not using a good approach. If any, please guide me in the right direction.
This is the scenario: I've an Activity
and a bound Service
. The Service
holds some data and processes it as necessary while posting a persistent (ongoing) notification with some information. The Activity
has three Fragments
inside a ViewPager
that displays the data processed by the Service
.
The Fragments
are a List Fragment, that shows the active data entries available, a Details Fragment that displays the details for each data and a Parameters Fragment where the user can modify how the data is processed.
[Service] <-> ([Activity] -> [ViewPager([List], [Details], [Parameters])])
Everything works just fine. My Activity
binds to the Service
, the ViewPager
is created after and then the Fragments
fetch information trough an Interface
.
Here comes the fun part... Screen Rotation!
As the Service
binds asynchronously, when the user rotates the screen the Fragments
no longer have the data because the Activity
is bounding the service while they're already present and not recreated thanks to the ViewPager
.
I've been trying to figure this out but it seems that I don't have the knowledge to solve it. I've tried making static references to the fragments, setting them up before the service is rebound but I can't get a stable solution.
I'd be using android:configChanges
in my manifest but there are different layouts for each orientation.
Again, if I'm using a bad approach, please, guide me!