Widgets and orientation changes
The widget in WiFi Manager initially didn’t work correctly on the Moto Milestone after orientation changes (fixed in 1.3 and later).
The main problem was: after sliding out the keyboard, widget views were reset to their original state (as in the layout file). The widget didn’t respond to clicks, either.
This is what I found out while fixing this issue:
- When orientation changes, it’s not possible for
AppWidgetProviderto be notified.
onUpdateis not called, and neither is any other notification method.
- The widget’s “real” views hosted in home screen process are destroyed and recreated (as uaual, from xml layout file).
- Android correctly uses appropriate -land or -port layout for the previous step.
- After the layout is inflated,
Androiduses the most recent
RemoteViewsobject (which it saves somewhere) to bring your widget up to date.
- Create separate layouts for -port and -land orientations.
- Orientation-dependent data presentation differences should be handled by your widget’s layouts (i.e.
TextViewellipsize), not on the
AppWidgetProviderside (i.e. measuring and trimming text)
- This is the most important: make sure each
RemoteViewsobject you push to the widget completely specifies widget state, including states of all views and all