I have Parcelable
object that holds a query
and offset
to web API.
Then I have two Activities:
Activity
A with a list and Activity
B with a ViewPager
. User navigates from Activity
A to B, and Parcelable
is passed in Intent
. In Activity
A query is persisted using onSaveInstanceState
. (initial offset
is 0 )
Inside Activity
B activity user can swipe and offset can be increased. (offset
increased to 20 )
Then user can navigate back to Acitvity
A with list. In Activity
A query is restored from savedInstanceState
. ('offset` is 0 but should be 20 )
What is the best way to maintain such offset state between those two Activities? I want to avoid saving it to shared preferences.
You can start Activity B 'forResult', and when navigating back to Acivity A, set the result including the offset, so you can access it in Activity A in
onAcivityResult()
And refresh the value accordingly...