I just fixed a bug in our application. The problem was that docking or undocking the device causes the application to restart. The fix, which I found after trawling loads of forum threads, was to append uiMode to the android:configChanges attribute in the AndroidManifest.xml file:
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustPan">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Adding something to the
android:configChanges tells Android that you will handle the specific events yourself in
onConfigurationChanged in the Activity class (or ignore them). If you specify something there Android won't do anything itself in case of an event being triggered which would be the Activity recreation in case of docking/undocking.
In the normal case you don't break anything as long as you don't change your layout for example in case of such an event.