Quote:
Originally Posted by Renate
Ok, here's a tip (that I just discovered for myself) for you app developers.
When a Bluetooth clicker appears Android says to itself, "OMG, something just appeared that can do a page down" and it restarts the foreground application so that it can take advantage of this startling info. In AndroidManifest.xml you can put:
Code:
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode|navigation">
This tells Android to keep its hat on and that you can roll with the punches without your app having to restart. Most of the clauses you will recognize but the uiMode and navigation were new to me. If you want, you can address the changes in onConfigurationChanged in your Activity.
All of this only comes into question if you connect your Bluetooth device after your app is already started.
|
It isn't a good advice to tell people to handle the changes themselves unless they're programming a game or the app cannot/doesn't follow android best practices. It is usally way better to let the framework to restart you app and recover the previous state from the bundle you get for free in onCreate.
99'9999% of apps handle orientation without problems and without the users noticing that the app was destroyed and recreated based on previous state.
Also keep in mind that screenSize et al can modify your device's dpi and require a whole different set of drawables. Handling drawables by hand isn't funny