5 ms·
It's a pretty terrible design to couple activity state to the physical orientation of the device.
by sidlls 9y ago
It's a pretty terrible design to couple activity state to the physical orientation of the device.
- jschwartzi 9y agoTo be fair, there may have been really good reasons for it back when Android devices had 500 Mhz single-core CPUs with 32 or 64 Megabytes of RAM.
- AstralStorm 9y agoStill good reasons when a web browser eats 500 MB.
- jonas21 9y agoYou can always handle the orientation change manually if you want to. But if you don't want to bother, restarting the Activity seems like a reasonable default.
- jayd16 9y agoNo, you don't understand. The state is serialized and stored. You might navigate away or pop into a windowed state. These things might rebuild your activity and the idea is your state should be serializable. The idea is every activity can be restarted outside of your control and your state should be fully storable.
- sidlls 9y agoNo, I understand the Android Activity lifecycle quite well. I think it has severe flaws from a design perspective.
- AstralStorm 9y agoNot from design, no. Design is pretty sound. It has implementation issues - you get to use a crusty ContentProvider or manually serialize everything into also crusty Bundle. Then you have that separate SharedPreferences thing. Or you can do it on your own, typically more cleanly, with an object database. Instead it would be often fine if it just took a Java Serializable and ran with it, just call you back so that you can read all the state and redo whatever you need to redo. Likewise IPC with Intents is pretty crusty as is with Binder, though bit less with the latter.
- hota_mazi 9y agoHow would you do it?