Answer the question
In order to leave comments, you need to log in
Android. Getting service reference in fragment and changing screen orientation?
There is an Activity, in it the service is launched and the binding (bind). As a result, in onServiceConnected() I get a link to the service. This link is used in snippets. The essence of the problem: when changing the orientation, the reference to the service is reset. What are the possible solutions here? Bind in each fragment?
Answer the question
In order to leave comments, you need to log in
The correct solution is to bind in each fragment. The fragment should be as independent as possible.
I don’t know what code you have and what and how, but when you change the orientation (and other other settings), the Activity is recreated with new settings, so that this does not happen, you need to specify in AndroidManifest.xml for the Activity android:configChanges="orientation"
: . site
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question