Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hm, I'll have to try that out!

Oh, on those. Compared to iOS and ViewControllers, they just isn't a comparison. Starting them? Oh, can I do new Activity()? Nope, use this Intent thing. Rotation? Good luck! Passing data around? I have to use a bundle? Why can't I set a variable inside, like any other object?

Just to start. :)



> Passing data around? I have to use a bundle? Why can't I set a variable inside, like any other object?

You can just set variables like normal Java just fine. The bundle thing is only necessary to preserve data across process deaths.


How do you set those variables? Do you keep a reference to your activity or fragment inside another screen? Do you clean up that reference on configuration change, or let it leak and/or cause crashes?

Your best bet to pass data around is to... not pass it but rather use a sophisticated DI setup where you can set up shared objects that live in a certain scope. Of course, you can add parameters to a bundle with some boilerplate, but that's not a great idea if the serialization overhead hurts you.


Neither the ViewModel library nor Activity#onRetainNonConfigurationInstance() is what I'd call a "sophisticated DI setup"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: