Hi all, I have been building an Android Library th...
# library-development
f
Hi all, I have been building an Android Library that starts internally an Activity. What is the best way of sending data ( complex object ) to this Activity? I think of a Kotlin object as singleton object (repository) to store all the config/data and fetch the data via this object in the Activity. Should I get back to pass parcelables instead ? Thanks in advance.
a
You should probably discuss it with android guys since it is not a general probem, but using global mutable state is usually bad idea. What happens when user kills application mid-transaction?
j
I think the idea behind activities was that each acts more or less as a webpage, and the transitioning between them happens the same way. You can pass things through parameters, but if they are to access data, they're expected to go through a database or some other truly persistent mechanism. One of the reasons behind this is the idea that you can scroll back through the apps you've opened and they'll always be exactly how you left them because they have no permanent state in RAM - everything can be persisted. I really don't like how this works personally, as it takes away from the safety of the language. I don't view opening an app that I had open over a week ago and getting the exact same state at as an important priority whatsoever, and many people would actually find it annoying. I usually want to go back to the first screen in the app if I'm opening it a few days later. As such, I usually just use a single activity in my projects and switch out views alone by holding view generators in static memory.
typealias ViewGenerator = (ActivityAccess)->View