I've been playing around with coroutines in Androi...
# coroutines
p
I've been playing around with coroutines in Android the last week. I've actually managed to use them to solve my biggest bugbear - Handling startActivityForResult, and the slightly less annoying handling of dialogs. The upside is that I've managed to make it work correctly. Thanks to Kryo I've even managed to make it survive activity/app restarts. Serialization isn't pretty and there are a number of serialization issues (I've worked around it by custom configuration). Runblocking from its semantics isn't really recoverable (what thread should it be deserialized on?) It does some nasty things with contexts to detect a context/activity and instead of serializing the activity it is passed an activity on deserialization which is put in its place (it's ugly but really works, and it is too easy to implicitly capture an an activity in your lambda's). The code is athttps://github.com/pdvrieze/darwinlib/blob/master/src/main/java/nl/adaptivity/android/coroutines/CoroutineActivity.kt (and related files). It's not very clean yet, but feedback is much appreciated.