N
N
nightmare02015-04-18 17:41:14
Android
nightmare0, 2015-04-18 17:41:14

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

2 answer(s)
N
nightmare0, 2015-04-19
@nightmare0

The correct solution is to bind in each fragment. The fragment should be as independent as possible.

I
IceJOKER, 2015-04-18
@IceJOKER

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 question

Ask a Question

731 491 924 answers to any question