Question

For the screen rotation, I've implemented attribute android:ConfigChanges="orientation|screenSize" in manifest file. Everything works fine. But this link here suggests to consider this approach to be last resort and not recommended one. What would be the better way of handling this screen rotation ? (FYI: My app implements multiple spinners to get info from user and then writes to a file. so by default, when a screen rotation happens, i would loose all info that user selected) help please.

Was it helpful?

Solution

What would be the better way of handling this screen rotation ?

Delete that attribute.

If you find that you need to pass information from the old activity instance to the new one, on the configuration change, you can put data in the Bundle you are passed in onSaveInstanceState(), and use that data in onRestoreInstanceState() to tailor your UI. In the case of a Spinner, you can pass the selected position this way, restoring it in the new activity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top