I have problems with my app on Asus Transformer TF101, with keyboard.
If i dock it to keyboard (or undock it) during displaying a activity, the activity is recreated. That means: onDestroy is called. onCreate is called.
Is it possible to catch the event that user is undocking or docking?
I would like to show a warning message, save the data and finish the activity..
Problem background: In my case, it changes the data in edittext fields, then user undocks or docks. I have created a tablelayout with edittexts fields, like editable datagrid. On Asus it messes up, then undocking, the system recreates the activity and all data in datagrid is rewritten automagically. All rows become like the last row. I assume that system does the redraw by ID's, but i have inflated the rows into datagrid, so the edit fields in rows have same ID's.
Try adding android:configChanges="keyboard" to your activity. See here and here for how runtime changes work with regards to Activities.
ReplyDeleteOn the other hand, if it's operating like a phone dock, then try listening for ACTION_DOCK_EVENT. See here for a tutorial. This would not explain why the activity is being recreated, though, while the above does.