My code works as expected on smaller and bigger devices (Motorola Xoom, Samsung Galaxy Player 4.0, Kyocera Digno), but for the Samsung Galaxy Tab 7.0, after launching an ACTION_IMAGE_CAPTURE
intent and taking a picture, when the app returns onDestroy()
is called, followed by onCreate()
, then onActivityResult()
is called, and finally, onDestroy()
and onCreate()
are called again, which is of course undesireable - only onActivityResult()
should be called.
Possibles clues:
- The Galaxy Tab 7.0 has a screen size that is explicity not supported in the manifest file (and this is the only device I have tested with an unsupported screen size), so the user may choose scretch-to-fit or zoom-to-fit. Both UIs have the same (bad) behavior.
- The camera activity seems to switch orientation when previewing a picture. My app only supports portrait mode (edit: on smaller screens - on non-xlarge screens, it supports orientation changes). Maybe the orientation change is destroying my activity, somehow.
- I have tried launching and returning from a different intent (email intent), and my app is not destroyed and re-created in that case.
Let me know if more information or a code sample is needed.
Edit: the issue has been narrowed down to the orientation change. As per Karthik's answer, setting android:configChanges="orientation"
fixes the issue. The only problem is, my app supports orientation changes on xlarge screens. This setting breaks this functionality on those devices. I've tried using android:configChanges="@string/config_changes"
and providing a different string depending on the screen size, but now I'm getting an "Installation error: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION". According to this, Android Activity, how to override manifest's android:configChanges with Java code?, there is no way to set it programmatically. Is my only option left to handle all orientation changes in my app manually?